Processing a MySQL Dump file with Python

Discussion in 'Python' started by Nico Grubert, Oct 4, 2004.

  1. Nico Grubert

    Nico Grubert Guest

    Hi there,

    I need to parse a textfile (~400 MByte) which represents a complete
    MySQL dump (including table definitions and data records) .
    How can I process a MySQL dump file with python? Is there any Python
    module that can parse MySQL dump files -- or
    can I somehow call the MySQL interpreter in background to pass the dump
    file to it so the SQL Dump is imported in order
    to write the tables and data into the MySQL database?

    Thanks in advance,
    Nico
     
    Nico Grubert, Oct 4, 2004
    #1
    1. Advertising

  2. Nico Grubert wrote:

    > can I somehow call the MySQL interpreter in background to pass the dump
    > file to it so the SQL Dump is imported in order
    > to write the tables and data into the MySQL database?


    Sure, that's what dump files are good for. Simply pipe the contents of the
    file into a mysql command. On a Unix-type system (maybe Windows too, I
    wouldn't know) you'd run something like:

    mysql -h myhost.com -p -u myusername < dumpfile

    MySQL does all this by itself, no Python required.

    Hope that helps,
    Jeffrey
     
    Jeffrey Froman, Oct 4, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JL
    Replies:
    0
    Views:
    1,178
  2. halfdog
    Replies:
    12
    Views:
    12,595
  3. Nico Grubert
    Replies:
    1
    Views:
    362
    Alex Martelli
    Oct 4, 2004
  4. Replies:
    2
    Views:
    6,254
  5. Wesley
    Replies:
    1
    Views:
    214
    Wesley
    Apr 15, 2014
Loading...

Share This Page