By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,563 Members | 1,066 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,563 IT Pros & Developers. It's quick & easy.

Script to export MySQL tables to csv

P: n/a
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.

Thanks
Jandre

Nov 10 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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

http://sourceforge.net/projects/mysql-python

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

You're going to have *such* fun!

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

Nov 10 '05 #2

P: n/a
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.

Thanks
Jandre

I recently had a need to do exactly what you are describing and
found this product to fit the bill nicely.

http://www.apexsql.com/sql_tools_diff.asp

Sometimes I find it better to buy than to write ;-).

Larry Bates
Nov 10 '05 #3

P: n/a
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 think the easiest way to compare tables in a SQL-based database is
using SQL ...

What about exporting the tables from the databases, importing those you
want to compare into one database and then using set-operations in SQL
using MINUS, INTERSECT. For example:

select c1, c2, c3 from table1
intersect
select c1, c2, c3 from table2;
-- return data common in both tables

select c1, c2, c3 from table1
minus
select c1, c2, c3 from table2;
-- data only in table1

etc.

You can export specific tables from a MySQL database using the mysqldump
commandline tool and then load them into the other database.

HTH,

-- Gerhard

Nov 10 '05 #4

P: n/a
Thnaks to everybody for their input. I have found a quick fix for now.
MySQL dump allows me to export the data to XML which can easily be
compared. This will help me for now and the project will have to wait
until I have some more time.

Regards
Jandre

Nov 22 '05 #5

P: n/a
Thnaks to everybody for their input. I have found a quick fix for now.
MySQL dump allows me to export the data to XML which can easily be
compared. This will help me for now and the project will have to wait
until I have some more time.

Regards
Jandre

Nov 22 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.