473,385 Members | 1,782 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Script to export MySQL tables to csv

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
5 9314
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Mike MacSween | last post by:
My client has an MS Access database application on her local machine. I have full access to that in terms of changing the design. I've got a simple PHP/MySql application on shared hosting, so no...
0
by: Priscilla Walther | last post by:
Hi All - I'm a newbie to the database area, but have inherited a MySQL database to manage along with my development duties. We have a very large MySQL database, and the designer of the...
1
by: Dave Crypto | last post by:
Hi there, SUMMARY: 1) When I use phpadmin to export a large database, the file created on my local PC never containes all the tables and information. It seems to max out at about 10mb. 2)...
5
by: Kajol | last post by:
Hi All, can u plz tell me how to import data from mysql to another database. & how to export data from anotherdata base to mysql Thanx for ur Advice Regards Kajol
7
by: phillip.s.powell | last post by:
We're looking at a GUI interface for our MySQL DB and I am interested in MySQL Administrator, however, one of our requirements is to be able to import/export databases. Is this possible or do I...
7
by: eselk | last post by:
I'm doing some speed tests. I created a brand-new table, with just one "Long Integer" field. I'm testing adding 1000 records. If I use the "Export" feature in Access, it takes only a few seconds...
12
by: Robbo | last post by:
Hi, My database contains 45 tables the structure of which is evolving as I develop. I need a utility that will "read" the structure of this database and it's tables and then create an identical...
15
by: Franz Marksteiner | last post by:
Hi folks, I am looking for the straightest way to export a whole MySql database, but all I can find is SQL statements to export specific tables. Any suggestions? -- Freundliche Grüße, Franz...
3
by: Edward Reid | last post by:
OK, I've been watching my DB grow and have known for a long time I would have to move the back end, but of course I waited until I started getting odd behavior (at about 1.92GB). So today I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.