Re: MySQL database export to Excel
| From: | Steve Staples | Date: | Fri, 26 Nov 2010 13:59:31 +0000 |
| Subject: | Re: MySQL database export to Excel | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-309681@lists.php.net to get a copy of this message | ||
On Fri, 2010-11-26 at 15:21 +0200, Sotiris Katsaniotis wrote:
> Greetings fellow PHP developers!
>
> I am looking of a relatively simple way to export a whole database into
> an Excel file. I have several methods to export tables to Excel files
> but unfortunately I have failed to export a whole database!
>
> Can someone be so kind to point me in the right direction?
>
> Thanks a lot!
>
DISCLAIMER
This is untested, and just off the top of my pointy head, do some
research, and know how much strain this COULD put on your system.
/DISCLAIMER
there are MANY MySQL commands that you can use, and combine them into 1
script, and then export them into excel, using multiple pages with
something like this:
http://www.codediesel.com/php/creating-excel-documents-in-php/
example mysql queries:
SHOW DATABASES; -- gets a lits of all the databases (skip MySQL and
information_schema)
SHOW TABLES FROM {tablename}; -- gets all the tables in a specific
database
SELECT column_name FROM information_schema.columns WHERE
table_name='{tablename}' AND table_schema='{databasename}'; -- gets you
a list of all the column headers (there are other ways you can avoid
doing this, but this works)
SELECT * FROM {databasename}.{tablename}; -- gets all the rows from a
table in the database
if you were to create a script, and providing your scipt has enough
"max_execution_time", and "memory_limit" (should prolly be done from the
CLI) you can prolly get it done...
and yeah, this is a pointer to how it *COULD* be done, but it's not the
only way, nor is it prolly the best either.
Good Luck, and if you need more MySQL related questions answered, try
the mysql@lists.mysql.com mailing list. they are really good over
there.
Steve