[Qt-interest] retreive list of databases from MySQL database
Robert Hairgrove
evorgriahr at hispeed.ch
Mon Mar 8 22:14:15 CET 2010
Andre Somers wrote:
> Hi,
>
> I am trying to show the user of my application a list of available
> databases to connect to on my SQL database. MySQL features the SHOW
> DATABASES command. Is there some way to issue this command using
> QSqlQuery before actually connecting to a known database on the server?
>
> André
From the MySQL docs (look at chapter 19.1):
" The following statements are equivalent:
SELECT SCHEMA_NAME AS `Database`
FROM INFORMATION_SCHEMA.SCHEMATA
[WHERE SCHEMA_NAME LIKE 'wild']
SHOW DATABASES
[LIKE 'wild']"
If the user which has logged into the MySQL server has SELECT privileges
on the INFORMATION_SCHEMA database, you can use that SELECT statement to
do what you want. If not, it won't work (you also cannot use SHOW
DATABASES with that user account).
More information about the Qt-interest-old
mailing list