Re: Processing a MySQL Dump file with Python

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

  1. Nico Grubert

    Nico Grubert Guest


    >>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.



    Hi Jeffrey,

    thank you for you reply.
    Calling the MySQL interpreter manually in a shell and pass a dump file
    on a unix-type system like:

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

    works fine for me.

    What I need to do is calling "mysql -h myhost.com -p -u myusername <
    dumpfile" directly from python.
    How can I do this in python?

    Does the _mysql python interface provide a method that imports a MySQL
    dump file? I did not find
    anything in the API of _mysql python interface.

    Kind regards,
    Nico
     
    Nico Grubert, Oct 4, 2004
    #1
    1. Advertising

  2. Nico Grubert <> wrote:
    ...
    > What I need to do is calling "mysql -h myhost.com -p -u myusername <
    > dumpfile" directly from python.
    > How can I do this in python?


    import os
    os.system("mysql -h myhost.com -p -u myusername dumpfile")


    Alex
     
    Alex Martelli, 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,590
  3. Nico Grubert

    Processing a MySQL Dump file with Python

    Nico Grubert, Oct 4, 2004, in forum: Python
    Replies:
    1
    Views:
    780
    Jeffrey Froman
    Oct 4, 2004
  4. Replies:
    2
    Views:
    6,251
  5. Wesley
    Replies:
    1
    Views:
    214
    Wesley
    Apr 15, 2014
Loading...

Share This Page