Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I still prefer to use mysql command line for this task. If you think you have to use a perl sript, then I assume you have remote access to the DB server, in which case you can also use the mysql client from your host.

SQL files (.sql) are meant to be executed in batch mode, each statement is terminated with a semicolon (";"). With DBI, you execute query one statement at a time and semicolons are disliked :-)

Finally, if you still need a perl script to automate DB updating (still assuming you the remote access), this might help (sorry, I don't bother to test it).

#!/usr/bin/perl use strict; use warnings; my $sql_file = '/path/to/sql/file.sql'; exit 0 # silently unless -r $sql_file; my $user = 'user'; my $pass = 'pass'; my $db = 'somedb'; system "mysql -u$user -p$pass $somedb < $sql_file" and die "can't update $db\n";
Also, you may want to consider about DB backup and/or hotcopy, as both facilities are provided by mysql, AFAIK.

Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!


In reply to Re^3: Import dump file into mysql DB using DBI by naikonta
in thread Import dump file into mysql DB using DBI by siva kumar

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-03-28 21:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found