473,811 Members | 2,859 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 9336
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
4207
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 direct access to the db server. I'd like to give her the facility to export the information in her local Access application to the shared PHP/MySql site. From one command button (or similar) in the Access application.
0
7818
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 database no longer works for us. I need to re-create the same table structure, but without the content, on a separate machine. I know I can do a show tables on the existing db, and also a describe on
1
4046
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) Will running mysqldump from command line on a live in-use DB (with one table containing 350,000 rows) pose any risks and have any large effect of current use?
5
3315
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
33424
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 need to know else (e.g. Navicat)? Thanks Phil
7
3584
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 to export the 1000 records to a new table on the server. If I use my code below, it takes 100 secods (10 records per second). Can someone help me speed up my code? --- code --- Dim con As New ADODB.Connection
12
4560
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 database with all tables. Can you help please ?
15
3305
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 Marksteiner
3
4564
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 installed MySQL and (after a bit too much time getting the data source working) started exporting tables. I successfully exported eight of my nine tables, and can view them from a linked Access front end. But when I tried to export the final table,...
0
9722
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9603
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10644
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10379
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10124
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6882
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3863
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.