Results 1 to 8 of 8

Thread: PyQt5:QMYSQL driver not loaded

  1. #1
    Join Date
    Jun 2019
    Posts
    6
    Thanks
    1
    Qt products
    Qt5

    Default PyQt5:QMYSQL driver not loaded

    Hi,
    I got a problem on connecting database on my project.
    I use PyQt5.QSqlDatabase for connecting but a error occured.
    Qt Code:
    1. from PyQt5.QtSql import *
    2.  
    3. class Database():
    4. def __init__(self,hostname,user,dbase,pword=""):
    5. self.db=QSqlDatabase.addDatabase("QMYSQL")
    6. self.db.setHostName(hostname)
    7. self.db.setDatabaseName(dbase)
    8. self.db.setUserName(user)
    9. self.db.setPassword(pword)
    10. ok = self.db.open()
    11.  
    12. mydb=Database("localhost","root","billingsys")
    To copy to clipboard, switch view to plain text mode 

    Error is:
    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: PyQt5:QMYSQL driver not loaded

    You need to build and install the Qt MySQL database plugin before QT or PyQT5 can load it.
    See here: QMYSQL for MySQL 4 and higher

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,229
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: PyQt5:QMYSQL driver not loaded

    @Juliehannah: If you continue to post links to unrelated commercial web sites, I will report you as a spammer and ask for your username to be deleted. This is the only warning I'll give.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  4. #4
    Join Date
    Mar 2020
    Posts
    3
    Platforms
    Unix/X11 Windows

    Default Re: PyQt5:QMYSQL driver not loaded

    Quote Originally Posted by RamrajCh View Post
    Hi,
    I got a problem on connecting database on my project.
    I use PyQt5.QSqlDatabase for connecting but a error occured.
    Qt Code:
    1. from PyQt5.QtSql import *
    2.  
    3. class Database():
    4. def __init__(self,hostname,user,dbase,pword=""):
    5. self.db=QSqlDatabase.addDatabase("QMYSQL")
    6. self.db.setHostName(hostname)
    7. self.db.setDatabaseName(dbase)
    8. self.db.setUserName(user)
    9. self.db.setPassword(pword)
    10. ok = self.db.open()
    11.  
    12. mydb=Database("localhost","root","billingsys")
    To copy to clipboard, switch view to plain text mode 

    Error is:
    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7
    Hi, I have ran into same problem.I have looked almost every link which is a suggested solution to this but most of them are about QT not PyQT and none of them worked for me anyway.

    Did you find a solution to this ?? If so please help me.

    I am using Windows 10 OS, PyQt5.14.1, MySQL 8.0.19, mysql-connector-python 8.0.19.

    Please reply as soon as possible. I am stuck to this 2 last days.

    Thanks

  5. #5
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PyQt5:QMYSQL driver not loaded

    As ChrisW67 already said you have to build the driver on your own. Follow the instructions in link ChrisW67 gave above.

  6. #6
    Join Date
    Mar 2020
    Posts
    3
    Platforms
    Unix/X11 Windows

    Default Re: PyQt5:QMYSQL driver not loaded

    Quote Originally Posted by ChristianEhrlicher View Post
    As ChrisW67 already said you have to build the driver on your own. Follow the instructions in link ChrisW67 gave above.
    Correct me if I am wrong.
    Those are for Qt not for PyQt5. They used qmake but there is no file with name as qmake.exe or qmake.py in PyQt5 folder.

    I am using PyQt5 only not Qt.

    Can you guide me about how to build and install MYSQL driver for PyQt5 in windows 10 ?

    I did try to adding qsqlmysql.dll directly to ..Python37\Lib\site-packages\PyQt5\Qt\plugins\sqldrivers but that didn't work with error
    QMYSQL: driver not loaded, available driver QSQLITE, QMYSQL, QMYSQL3, ...

    I did find libmysql.dll and libmysql.lib in MYSQL SERVER folder but didn't find any link describing how to use them for PyQt5 in windows.

    Thanks

  7. #7
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PyQt5:QMYSQL driver not loaded

    PyQt just uses the Qt libraries through a wrapper so I don't see why this should not apply to you...

  8. #8
    Join Date
    Mar 2020
    Posts
    3
    Platforms
    Unix/X11 Windows

    Default Re: PyQt5:QMYSQL driver not loaded

    Quote Originally Posted by adarsh1783 View Post
    Correct me if I am wrong.
    Those are for Qt not for PyQt5. They used qmake but there is no file with name as qmake.exe or qmake.py in PyQt5 folder.

    I am using PyQt5 only not Qt.

    Can you guide me about how to build and install MYSQL driver for PyQt5 in windows 10 ?

    I did try to adding qsqlmysql.dll directly to ..Python37\Lib\site-packages\PyQt5\Qt\plugins\sqldrivers but that didn't work with error
    QMYSQL: driver not loaded, available driver QSQLITE, QMYSQL, QMYSQL3, ...

    I did find libmysql.dll and libmysql.lib in MYSQL SERVER folder but didn't find any link describing how to use them for PyQt5 in windows.

    Thanks
    I uninstalled PyQt5 5.14.1 and installed PyQt5 5.12.1 and everything work fine.

Similar Threads

  1. Replies: 3
    Last Post: 3rd June 2019, 09:59
  2. CentOS 6: QMYSQL driver not loaded, available driver: (none)
    By mp33919 in forum Installation and Deployment
    Replies: 1
    Last Post: 19th October 2016, 16:46
  3. QMysql Driver not loaded
    By Cerberus in forum Qt Programming
    Replies: 2
    Last Post: 1st November 2015, 20:55
  4. QMYSQL driver not loaded
    By robotics in forum Qt Programming
    Replies: 3
    Last Post: 26th July 2011, 13:43
  5. QMYSQL driver not loaded
    By sepehr in forum Qt Programming
    Replies: 12
    Last Post: 11th January 2009, 21:15

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.