Results 1 to 5 of 5

Thread: How to get list of all databases on the MySQL server

  1. #1
    Join Date
    Oct 2007
    Posts
    27
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to get list of all databases on the MySQL server

    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.

  2. #2
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to get list of all databases on the MySQL server

    I think if you execute the query SHOW DATABASES using QSqlQuery, the result will have all the available databases.

  3. #3
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to get list of all databases on the MySQL server

    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.
    A camel can go 14 days without drink,
    I can't!!!

  4. #4
    Join Date
    Oct 2007
    Posts
    27
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to get list of all databases on the MySQL server

    Thanks a lot. I will try both of solutions.

  5. #5
    Join Date
    Aug 2007
    Posts
    275
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to get list of all databases on the MySQL server

    Which one works best ? if you dont mind telling me here....

Similar Threads

  1. Staying connected to a MySQL server
    By fnmblot in forum Qt Programming
    Replies: 1
    Last Post: 22nd November 2007, 10:39
  2. Acces to a remote mysql server
    By Alienxs in forum Qt Programming
    Replies: 2
    Last Post: 19th August 2006, 03:10

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.