Code
MySQL Table Export to CSV
2010-01-08 04:26:32
Here's a little script I wrote to quickly and easily export a table from a MySQL database to a comma separated file. I know this can be done using some SQL commands, but I have been needing to repeat this processes more and more, so I decided to write a nice little interactive CLI script in PHP to make my life a little easier.
So here it is...
mysql_table_export.zip
To use it, simply unzip the php file and run it at the command line:
php mysql_table_export.php
It will then ask you a few questions, such as user credentials for the MySQL database server, the name of the database, the name of the table and the file where you want it to write the exported data to. It will also give you the opportunity to provide a WHERE clause, so you can add something like:
Where clause (optional) : WHERE `date` > '2010-01-01'
Enjoy, and let me know if you found it useful.
