PDA

View Full Version : How to get list of all databases on the MySQL server



jambrek
7th July 2008, 09:36
Hi,

I need to establish connection with MySQL server (localhost) and get list of ALL databases on this server. Is there any Qt's class or function to do that? I found QSqlDatabase class, but in this class I have to set name of exactly ONE database.

Thanks.

munna
7th July 2008, 09:57
I think if you execute the query SHOW DATABASES using QSqlQuery, the result will have all the available databases.

mcosta
7th July 2008, 09:58
If you use MySQL 5.x you can connect to INFORMATION_SCHEMA database and query the SCHEMATA Table.

Then you can create a QSqlDatabase for each Database.

jambrek
7th July 2008, 10:19
Thanks a lot. I will try both of solutions.

baray98
15th June 2009, 23:48
Which one works best ? if you dont mind telling me here....