Script to export MySQL tables to csv

Steve Holden steve at
Thu Nov 10 13:45:16 CET 2005

Jandre wrote:
> To anyone that can help
> I have 2 MySQL databases that contain large amounts of tables. I need
> to be able to compare the data in the tables with older/newer versions
> of the tables. I figured the easiest way would be to get the info in
> csv format and then run a comparison. I can get all the data using
> MySQL front, but this has to be done tabe-by-table, and is too time
> consuming.
> I am new to Python and also new to programming.
> Can anyone please help.
Well, it might be a rather extending first programming project, but the 
delightful news is that you can access MySQL databases directly from Python!

What sort of differences will exist? Does a row's content always stay 
the same once it's been written to a table, or are rows updated as well?

Basically if you can say what type of differences you want to see it 
should be possible to do just what you want.

If you haven't already downloaded and installed the MySQLdb module for 
Python you'll probably need that. Are you running on Windows or a 
Unix-like system (you'll need to get the appropriate installer from

If you have any trouble installing it, get back on this list and someone 
will help.

You're going to have *such* fun!

Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC           
PyCon TX 2006        

More information about the Python-list mailing list