Processing a MySQL Dump file with Python

N

Nico Grubert

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
 
J

Jeffrey Froman

Nico said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,538
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top