WARNING:I'm no expert with mysql, but I use it a lot.

Have you actually tried mysql app ? it's very slick and easy.

Simple one two three.. slurp the file with your commands.. then do

$handle->prepare($allyourcommands); $handle->execute(); #that will do it.

For example; I have a txt file with commands for creating a table and place some records:

create table usertypes ( usertype varchar(5) not null, usertype_label varchar(25) default 'user', usertype_child_create TINYINT(1) DEFAULT 0, usertype_child_assign_to_file TINYINT(1) DEFAULT 0, usertype_child_assign_to_dir TINYINT(1) DEFAULT 0, usertype_child_share TINYINT(1) DEFAULT 0, usertype_child_toggle_live TINYINT(1) DEFAULT 0, usertype_child_delete TINYINT(1) DEFAULT 0, usertype_child_admin_all TINYINT(1) DEFAULT 0, usertype_file_view_all TINYINT(1) DEFAULT 0, usertype_file_download TINYINT(1) DEFAULT 0, usertype_file_move TINYINT(1) DEFAULT 0, usertype_file_rename TINYINT(1) DEFAULT 0, usertype_dir_recurse TINYINT(1) DEFAULT 0, usertype_dir_create TINYINT(1) DEFAULT 0, usertype_dir_file_upload TINYINT(1) DEFAULT 0, usertype_dir_incoming_file_upload TINYINT(1) DEFAULT 1, usertype_dir_rename TINYINT(1) DEFAULT 0, usertype_edit_description TINYINT(1) DEFAULT 0, usertype_note TINYINT(1) DEFAULT 0, usertype_scan_for_new_files TINYINT(1) DEFAULT 0, usertype_usertypes_edit TINYINT(1) DEFAULT 0, usertype_view_all_sessions TINYINT(1) DEFAULT 0, row_last_modify integer(10), PRIMARY KEY (usertype) ); INSERT INTO usertypes ( usertype, usertype_label, usertype_child_create, usertype_child_assign_to_dir, usertype_child_toggle_live, usertype_child_delete, usertype_child_admin_all, usertype_file_view_all, usertype_dir_recurse, usertype_dir_rename, usertype_file_move ) values ('a','admin',1,1,1,1,1,1,1,1,1); INSERT INTO usertypes ( usertype, usertype_label, usertype_child_create, usertype_child_assign_to_file, usertype_child_toggle_live, usertype_child_delete, usertype_file_view_all, usertype_edit_description, usertype_file_download, usertype_child_admin_all, usertype_file_rename, usertype_dir_rename, usertype_file_move ) values ('m','manager',1,1,1,1,1,1,1,1,1,1,1); INSERT INTO usertypes (usertype, usertype_label, usertype_file_downloa +d) values ('u','user',1);

I can just cut and paste that into the mysql prompt or feed it through the handle.


In reply to Re: How do I execute an SQL file through DBI by leocharre
in thread How do I execute an SQL file through DBI by Limbic~Region

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.