Giter Site home page Giter Site logo

thecodemonkey86 / qt_mysql_driver Goto Github PK

View Code? Open in Web Editor NEW
346.0 19.0 51.0 246 KB

Typical symptom: QMYSQL driver not loaded. Solution: get pre-built Qt SQL driver plug-in required to establish a connection to MySQL / MariaDB using Qt. Download qsqlmysql.dll binaries built from official Qt source code

License: Other

qsqldatabase mysql sql-driver mysql-library dll qt5 cpp qt6

qt_mysql_driver's People

Contributors

thecodemonkey86 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qt_mysql_driver's Issues

How to use with PySide6?

I could make it work in PySide6,

did anyone succeed in accessing MariaDB databases from PySide6?

Qt: 5.15.12

Hi I was wondering if you could a release of Qt: 5.15.12 I am trying to add some files in order to enable support for Kate (the editor) and it shows the connection dialog with Qt:5.15.3 but it crashes.

Probably a binary version mismatch.

Thanks.

Any chance of V5.12.3?

Kia ora @thecodemonkey86
Thank you SO much for providing this. Seriously! I have to admit it's stumped me; I just need to make my application cross-platform, but don't know where to START with compiling in Windows and never want to.
For complicated reasons, I have to use Anaconda for this particular application, and the most recent pyqt version available is 5.12.3 - I'm wondering if there is any chance you might be prepared to compile and release that version? I am using mysql-connector-python 8.0.22
Yours very hopefully, Jamie

Cannot get field default value from the database

Cannot get columns default values from the database either through QSqlTableModel.record() nor QDatabase().record(), always None. Also setDefaultValue() does nothing. all field datatypes. Working with sqlite database.

I use Windows 11 x64, PyQt6 v6.6.2 and MySql Community server v8.0.32. I tried also with PyQt5 and other versions of PyQt6

Qt 6.2.3

Hi!

Can you provide a build for Qt 6.2.3? The 6.2.2 build causes a CTD.

Regards,
Abdullah Radwan

Qt5.9.9 MinGW 32bit?

Can you please provide also the qt_mysql_driver for the version mentioned above?

QMYSQL Driver not loaded

Greetings
You were kind enough to provide the plugin for 5.12.3
I've copied the libmysql.dll and qsqlmysql.dll into a subdirectory of my application called sqldrivers.
It still sadly says, "QMYSQL driver not loaded"
I am deploying a python application using pyinstaller, and the application has been built with an anaconda environment. I suspect that probably it's looking for the libraries somewhere and not finding them when it freezes the code. I'm so sorry to trouble you with this, but wonder if you have any experience with such a scenario? I've had no problems with the Linux and Mac platforms, for this application, but my inexperience with Windows is most likely to blame here. I'd be very very grateful for any pointers, please! With grateful thanks, Jamie

QMySqlDrivers not Working

I dont know if im just Stupid or what.
But i dont seem to get it to Work at all.
Im Trying to get the MySqlDrivers to Work but even after 8 Hours Compiling and Trouble shooting it wont work for me.

Information im not using QTDesign Studio. Im just using the Designer and PyQT6 with QT 6.5.1 (i also tryed downloading your Precompiled drivers)
Even after trying some of the Suggestions from your Solved Issues.
Copying them into the PyQt6 Python folder and also into the folder where the main.py is. Im getting this error:

QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QODBC QPSQL

Im totaly lost right now.

QSqlDriver::hasFeature(Transactions) returns false

so I'm not sure if this is a problem related to the linked dll or the compiled plugin or some incompatibility between the server and the connector but on windows Qt 5.15.3 and mysql server 8.0.29(on a linux host), this problem occurs.

Driver not loaded error. Are the plugins debug or release plugins?

Hello!

I had a strange issue with the built plugins for MySql on your page, they worked for a time and then they just stopped for some reason and I have not been able to get them operating again.

I have switched over to PySide6 (6.5.2) and downloaded the latest built plugin (6.5.2) and followed the answer at the bottom on this Stackoverflow page to the letter: https://stackoverflow.com/questions/64056483/unable-to-load-qmysql-driver-on-pyside2

Nothing works... Do you have any suggestion before I move my entire database module over to postgres, psycopg2 and construct the QTable by hand?

This is the output of my launching of the database connection (pretty common for sure but impossible to fix):

QMARIADB
QMYSQL
QSQLITE
QODBC
QPSQL
Failure to open database. Fatal error
<PySide6.QtSql.QSqlError("", "Driver not loaded", "Driver not loaded") at 0x00000254539F6FC0>

Tutorial

Any chance there's an update video on how to properly do it? It's not working on my end.

use QMYSQL driver 5.15.7, QMYSQL Driver is in available drivers, but can't loaded

PyQt5 5.15.7 version, download the QMYSQL driver 5.15.7 driver, where
Copy libcrypto-1_1-x64.dll, libssl-1_1-x64.dll, and libmysql.dll to the Qt5\bin directory, copy the sqldrivers directory to the Qt5\plugins\sqldrivers directory, and run the code in cmd :

from PyQt5.QtSql import QSqlDatabase
from PyQt5.QtCore import QCoreApplication

app = QCoreApplication([])
db = QSqlDatabase.addDatabase('QMYSQL')
db.setHostName(HOST)
db.setUserName(USER)
db.setPort(PORT)
db.setPassword(PWD)
db.setDatabaseName(DATABASE_NAME)
print(db.drivers())
if db.open():
    print('open success')
else:
    print('open failed')
print(db)

cmd output:

(PyQt5MySql) λ python mysql.py
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
['QSQLITE', 'QMARIADB', 'QMYSQL', 'QMYSQL3', 'QODBC', 'QODBC3', 'QPSQL', 'QPSQL7']
open failed
<PyQt5.QtSql.QSqlDatabase object at 0x0000000002875820>

mysql version is 8.0

Check the output information. The currently available driver is QMYSQL , but it still prompts that the loading failed(QSqlDatabase: QMYSQL driver not loaded). Do you know what the problem is? Looking forward to your reply.

environment

Package    Version
---------- -------
pip        22.2.2
PyQt5      5.15.7
PyQt5-Qt5  5.15.2
PyQt5-sip  12.13.0
setuptools 64.0.3
wheel      0.37.1

Qt 6.6.1 编译过程 (How do I compile it in qt 6.6.1 on Windows, Mingw 11.2.0)

@thecodemonkey86 thanks to thecodemonkey86, I compile it in qt 6.6.1 successfully, this is my note.Hope can help you.
By the way, i install mysql8 on my windows 11.

  1. Copy mysql lib path and head path to other dir. Because I got some errors like Permission denied or No such file or directory ,so change it in a simple path.
    复制 mysql 头文件和 lib 库到一个简单目录,避免玄学问题。
C:\Program Files\MySQL\MySQL Server 8.0\include -> D:\mysql\include 
C:\Program Files\MySQL\MySQL Server 8.0\lib -> D:\mysql\lib
  1. Build qmysql.dll using cmake gui and cmake cmake --build build --target install.
    使用 cmake-gui 和 cmake 命令 cmake --build build --target install 构建 qmysql.dll。
    image
    image
  2. Copy driver from C:\Program Files (x86)\QSQLiteDriverPlugins\plugins\sqldrivers to D:\Qt\6.6.1\mingw_64\plugins\sqldrivers
    复制 qsqlmysql 驱动到 qt 插件目录。
    image
  3. Try to print all QSqlDatabase::drivers , But i found it is empty, and using ChatGpt, it tells me i need set plugins path.
    打印看看是否有 mysql 驱动,如果找不到,把目录加进去,
QCoreApplication::addLibraryPath("D:/Qt/6.6.1/mingw_64/plugins");
qDebug() << QSqlDatabase::drivers();

image
6. Copy qsqlmysql.dll to project build path like build-opcTrans-Desktop_Qt_6_6_1_MinGW_64_bit-Release\sqldrivers.
复制qsqlmysql.dll 到 exe 输出目录下sqldrivers目录,没有建一个。
image
7. Copy libmysql.dll to project build path like build-opcTrans-Desktop_Qt_6_6_1_MinGW_64_bit-Release.
复制libmysql.dll 到 exe 输出目录下。
image
8. Try to connect db.
然后就可以试试了。

 QCoreApplication::addLibraryPath("D:/Qt/6.6.1/mingw_64/plugins");
    qDebug() << QSqlDatabase::drivers();
    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    db.setHostName("ip");
    db.setPort(3306);
    db.setDatabaseName("dbname");
    db.setUserName("user");
    db.setPassword("password");
    bool ok = db.open();
    if (ok){
        qDebug() << "OK";
    }
    else {
        QSqlError error = db.lastError();
        qDebug()<<"error open database because"<< error.text();
    }

Here are libmysql.dll。我自己编译的文件。
libmysql.zip
qsqlmysql.dll
sqldrivers.zip

Cannot load the driver from PyQt5

Hi,
I'm unable to load the driver using a pyqt5 app, for my environment pyqt5 is installed through pip and the version is 5.15.2 so I downloaded the following version qsqlmysql.dll_Qt_SQL_driver_5.15.2_MSVC2019_64-bit.zip since I know that PyQt5 is compiled with msvc and not mingw i placed the files in this directory:
C:\Users\mohammad\AppData\Local\Programs\Python\Python38\Lib\site-packages\PyQt5\Qt\plugins\sqldrivers
along with the libssl,libmysql and libcrypto dlls for simplicity.
I then used https://github.com/lucasg/Dependencies/ to check the qmysql.dll for a missing dependency and there doesn't seem anything missing.

than I used the following script to test:

from PyQt5 import QtCore
from PyQt5 import QtWidgets
from PyQt5 import QtSql
import sys



app = QtWidgets.QApplication(sys.argv)



database = QtSql.QSqlDatabase()

database.addDatabase("QMYSQL")

print("QT version is: {}".format(QtCore.QT_VERSION_STR))
print("Library path is {}".format(QtCore.QCoreApplication.libraryPaths()))

And I got the following output:

PS C:\Users\mohammad\Desktop> python .\qsqldatabase.py
QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/platforms" ...
QFactoryLoader::QFactoryLoader() looking at "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/platforms/qminimal.dll"
Found metadata in lib C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/platforms/qminimal.dll, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "minimal"
        ]
    },
    "archreq": 0,
    "className": "QMinimalIntegrationPlugin",
    "debug": false,
    "version": 331520
}


Got keys from plugin meta data ("minimal")
QFactoryLoader::QFactoryLoader() looking at "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/platforms/qoffscreen.dll"
Found metadata in lib C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/platforms/qoffscreen.dll, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "offscreen"
        ]
    },
    "archreq": 0,
    "className": "QOffscreenIntegrationPlugin",
    "debug": false,
    "version": 331520
}


Got keys from plugin meta data ("offscreen")
QFactoryLoader::QFactoryLoader() looking at "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/platforms/qwebgl.dll"
Found metadata in lib C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/platforms/qwebgl.dll, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "webgl"
        ]
    },
    "archreq": 0,
    "className": "QWebGLIntegrationPlugin",
    "debug": false,
    "version": 331520
}


Got keys from plugin meta data ("webgl")
QFactoryLoader::QFactoryLoader() looking at "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/platforms/qwindows.dll"
Found metadata in lib C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/platforms/qwindows.dll, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "windows"
        ]
    },
    "archreq": 0,
    "className": "QWindowsIntegrationPlugin",
    "debug": false,
    "version": 331520
}


Got keys from plugin meta data ("windows")
QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/platforms" ...
loaded library "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/platforms/qwindows.dll"
QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/platformthemes" ...
QFactoryLoader::QFactoryLoader() looking at "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/platformthemes/qxdgdesktopportal.dll"
Found metadata in lib C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/platformthemes/qxdgdesktopportal.dll, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformThemeFactoryInterface.5.1",
    "MetaData": {
        "Keys": [
            "xdgdesktopportal",
            "flatpak",
            "snap"
        ]
    },
    "archreq": 0,
    "className": "QXdgDesktopPortalThemePlugin",
    "debug": false,
    "version": 331520
}


Got keys from plugin meta data ("xdgdesktopportal", "flatpak", "snap")
QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/platformthemes" ...
QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/styles" ...
QFactoryLoader::QFactoryLoader() looking at "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/styles/qwindowsvistastyle.dll"
Found metadata in lib C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/styles/qwindowsvistastyle.dll, metadata=
{
    "IID": "org.qt-project.Qt.QStyleFactoryInterface",
    "MetaData": {
        "Keys": [
            "windowsvista"
        ]
    },
    "archreq": 0,
    "className": "QWindowsVistaStylePlugin",
    "debug": false,
    "version": 331520
}


Got keys from plugin meta data ("windowsvista")
QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/styles" ...
loaded library "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/styles/qwindowsvistastyle.dll"
QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers" ...
QFactoryLoader::QFactoryLoader() looking at "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/libcrypto-1_1-x64.dll"
"Failed to extract plugin meta data from 'C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/libcrypto-1_1-x64.dll'"
         not a plugin
QFactoryLoader::QFactoryLoader() looking at "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/libmysql.dll"
"Failed to extract plugin meta data from 'C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/libmysql.dll'"
         not a plugin
QFactoryLoader::QFactoryLoader() looking at "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/libssl-1_1-x64.dll"
"Failed to extract plugin meta data from 'C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/libssl-1_1-x64.dll'"
         not a plugin
QFactoryLoader::QFactoryLoader() looking at "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlite.dll"
Found metadata in lib C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlite.dll, metadata=
{
    "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
    "MetaData": {
        "Keys": [
            "QSQLITE"
        ]
    },
    "archreq": 0,
    "className": "QSQLiteDriverPlugin",
    "debug": false,
    "version": 331520
}


Got keys from plugin meta data ("QSQLITE")
QFactoryLoader::QFactoryLoader() looking at "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlmysql.dll"
Found metadata in lib C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlmysql.dll, metadata=
{
    "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
    "MetaData": {
        "Keys": [
            "QMYSQL3",
            "QMYSQL",
            "QMARIADB"
        ]
    },
    "archreq": 0,
    "className": "QMYSQLDriverPlugin",
    "debug": false,
    "version": 331520
}


Got keys from plugin meta data ("QMYSQL3", "QMYSQL", "QMARIADB")
QFactoryLoader::QFactoryLoader() looking at "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlmysqld.dll"
Found metadata in lib C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlmysqld.dll, metadata=
{
    "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
    "MetaData": {
        "Keys": [
            "QMYSQL3",
            "QMYSQL",
            "QMARIADB"
        ]
    },
    "archreq": 1,
    "className": "QMYSQLDriverPlugin",
    "debug": true,
    "version": 331520
}


"The plugin 'C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlmysqld.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)"
         not a plugin
QFactoryLoader::QFactoryLoader() looking at "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlodbc.dll"
Found metadata in lib C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlodbc.dll, metadata=
{
    "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
    "MetaData": {
        "Keys": [
            "QODBC3",
            "QODBC"
        ]
    },
    "archreq": 0,
    "className": "QODBCDriverPlugin",
    "debug": false,
    "version": 331520
}


Got keys from plugin meta data ("QODBC3", "QODBC")
QFactoryLoader::QFactoryLoader() looking at "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlpsql.dll"
Found metadata in lib C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlpsql.dll, metadata=
{
    "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
    "MetaData": {
        "Keys": [
            "QPSQL7",
            "QPSQL"
        ]
    },
    "archreq": 0,
    "className": "QPSQLDriverPlugin",
    "debug": false,
    "version": 331520
}


Got keys from plugin meta data ("QPSQL7", "QPSQL")
QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/sqldrivers" ...
Cannot load library C:\Users\mohammad\AppData\Local\Programs\Python\Python38\lib\site-packages\PyQt5\Qt\plugins\sqldrivers\qsqlmysql.dll: The specified module could not be found.
QLibraryPrivate::loadPlugin failed on "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlmysql.dll" : "Cannot load library C:\\Users\\mohammad\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\PyQt5\\Qt\\plugins\\sqldrivers\\qsqlmysql.dll: The specified module could not be found."
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
QT version is: 5.15.2
Library path is ['C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins', 'C:/Users/mohammad/AppData/Local/Programs/Python/Python38']
QLibraryPrivate::unload succeeded on "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/styles/qwindowsvistastyle.dll"
QLibraryPrivate::unload succeeded on "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/platforms/qwindows.dll"

What did I do wrong?

MySQL: Unable to set the client character set to utf8 (""). Using 'utf8' instead.

Hello,

I recently upgraded my app Qt version from 5.15.2 to 6.2. I can connect successfully but I always have this message while trying to do so: MySQL: Unable to set the client character set to utf8 (""). Using 'utf8' instead.

I didn't specify any character set in the connection options:

db = QSqlDatabase::addDatabase("QMYSQL", "DbOp");

db.setHostName("hostname.com");

db.setUserName("developer");

db.setPassword("password");

db.setDatabaseName("database_name");

I didn't have this message with Qt 5.15.2.

OCI Driver

Could you please be able to atleast try build and oci driver for windows(qt5.15.2/msvcX64) ?

I've spent much time but in the end it always ends up in an error.

I've asked in forum but it also ended up in an error.

5.15.4 version?

The current pyqt5 version on pypi is 5.15.4 can you provide a build for that verison

Guidance/instructions for adding files to PyInstaller package?

With the generous support of others, I managed to get MySQL 8.03 working with PyQt5 on my Windows development system. [see issue #29.] The work as gone well and I am now trying to use PyInstaller to create a deployable package. And of course, I am seeing the dreaded "QMYSQL driver not loaded" error again. Not a great surprise, as I am sure I have to manually include a couple MySql libraries in the package to make things work. This issue is probably related to issue #8 asked and closed a while ago, but no details about the fix were provided.

Cany anyone provide me with instructions or guidance about what needs to be done?

Bob

Testing MySQL connection

Hi, thanks a lot for posting this build - I've been trying to connect to a MySQL database using Qt for ages and this seems like a massive step forward compared to trying to build from source code in Windows 10. I've installed the dll's as per instructions and I'm not having any luck with getting data from my database. Here is the code I'm using to try to connect:

from mysql.connector import connect, Error
from PyQt5.QtSql import QSqlDatabase, QSqlQuery

db = QSqlDatabase('QMYSQL')
db.setDatabaseName('monty')
db.setPort(3306)
db.setHostName('127.0.0.1')
db.setUserName('graham')
db.setPassword('gilliam')
if not db.open():
    print('Could not open db')
print(QSqlDatabase.drivers())
print(db.tables())
query = QSqlQuery("SELECT * FROM parrot", db=db)
print('Records found: %d' % query.record().count())

try:
    with connect(host="localhost", user="graham", password='gilliam', database='monty') as connection:
        cursor = connection.cursor()
        query = 'SELECT * FROM parrot'
        cursor.execute(query)
        for(idOperator, first_name, last_name, email_address) in cursor:
            print("{} {} {}".format(
                first_name, last_name, email_address))

except Error as e:
    print(e)

and here is what is returned:
Could not open db
['QSQLITE', 'QMARIADB', 'QMYSQL', 'QMYSQL3', 'QODBC', 'QODBC3', 'QPSQL', 'QPSQL7']
[]
Records found: 0
John Palin [email protected]
Michael Idle [email protected]
Eric Cleese [email protected]

Process finished with exit code 0

As far as I can tell, the QSqlDatabase connection doesn't work, although the 'QMYSQL' driver is available. It doesn't open the db, and can't return tables or records. After trying the QSqlDatabase connection I've connected to the db using mysql-connector-python, and this seems fine (returns records). Is there some way of telling if there's something missing which is messing with the QSqlDatabase connection?

Thanks in advance,
Tim

They can work in PyQt5,but can not work in pyside2

I put files in the corresponding path of pyqt5 (sqldrivers path, bin path), it is available, but when I put it in the corresponding path of pyside2, there is no QMYSQL in the available drivers. There is no bin path in the path of pyside2, so I directly put libmysql.dll in the root directory of pyside2, and put the files in sqldrivers in the correct location. The python I use is the packaged version of anaconda. So I am confused.

mysql version

针对qt mysql dirver ,mysql 的版本只提到8.0,没有说是32位或64位的,目前社区版mysql官网都是32位的,而QT是64位 的,是否有问题?

Where are the QMYSQL drivers trying to find MySQL?

I need to create a desktop GUI app that I can deploy on both Windows and Linux systems using open source / public domain tools. The app has to read/write to MySQL database. The best solution seems to be Python and PyQt5 or 6. I'm trying to make Python 3.9 work with PyQt5 5.15 work on a Windows 10 system. After 5 days I finally tripped into this site and have loaded the qsqlmysql.dll and qsqlmysqld.dll files for Qt5 into my ...Qt5\plugins\sqldrivers folder. At least now I am able to see 3 MySQL drivers when I print QSqlDatabase.drivers(). [Thank you, progress at last...]

But, I'm still getting the all consuming "Driver not loaded Driver not loaded" as my last error when I try to open the database.

I have tried this on 2 different systems, 1 with MySQL 8.1 installed and one with MariaDB 10.9.2 installed. In each case I have tried all 3 of the drivers listed ('MIRIADB', 'MYSQL', 'MYSQL3') and get the same result.

It occurs to me that the problem might be that whatever file the QtSQL drivers are looking for, isn't where the drivers are looking.

Can anyone tell where and what to look for?

If I'm doing or overlooking something stupid, PLEASE point me in the right direction. I really need this to work...
Bob

Android MySQL

Hello,

Thank you for your efforts really appreciated it, I want to ask if there is an available driver for Android QT 6.3.0 Clang x86

Thanks

Driver is found but not loaded

Hello,

I have put the contents of sqldrivers into the sqldrivers folder inside the python folder that was in AppData. Now I don't know where excactly I should put the other files, so I put them into the folder before the sqldrivers folder of python (That is one of the folders I have added in path). It still doesn't load.
Also checked if the driver is the same version as my PyQt6 and it is both 6.1.

project file

Hello, in the readme it says: Unlike the original .pro file this project can be built in Qt Creator, the source code is however unchanged

But I cannot find any project file? How can one build or include this with only the .dll availiable?

Thanks though :)

A detailled way to build it yourself

Hi,

I was wondering f it was possible to give me/us a small step by step tutorial on how to build for Linux and/or Windows?
I somehow managed to grasp how to build it in Windows, but it was after following way to much different tutorials on Internet, but since you seem to already master it, f you could share it would be great.

Thanks in advance.

this is awesome

first i followed the official document ,try to build the plugin on windows,everything is fine ,but it always show QMYSQL driver not loaded, even the available drivers list contains the QMYSQL.i have being doing this all day,but still don't know why.
then i found this repo,just download it,it finally works!!!
thany you so much bro

qsqlmysql.dll: The specified procedure could not be found

Hey there! Thanks for this repository and your hard work. Can you help me find the source of my problem, if it's on my side or a bug?

Currently, when using version 6.6.2 on my project I get an intermitent error where data is not shown on QTableView . As far as I remember, I have no problem using version 6.6.1. Turns out I changed my computer/system, so I installed everything from scratch and version 6.6.1 stopped working. I did everything according to your documentation, the plugin is found and it tries to load. But I get this error:

qt.core.library: "C:/Users/jbope/Projetos/XXXX/resources/plugins/sqldrivers/qsqlmysql.dll" cannot load: Cannot load library C:\Users\jbope\Projetos\XXXX\resources\plugins\sqldrivers\qsqlmysql.dll: The specified procedure could not be found.
qt.core.plugin.loader: QLibraryPrivate::loadPlugin failed on "C:/Users/jbope/Projetos/XXXX/resources/plugins/sqldrivers/qsqlmysql.dll" : "Cannot load library C:\Users\jbope\Projetos\XXXX\resources\plugins\sqldrivers\qsqlmysql.dll: The specified procedure could not be found."

QSqlDatabase: QMYSQL driver not loaded

QSqlDatabase: available drivers: QSQLITE QMIMER QODBC QPSQL QMARIADB QMYSQL

What could be the missing "procedure"? How can I check that?

I checked dependencies and it doesn't seem to be the problem:

image

I tried every version of PySide6 6.*, with Python versions 3.8, 3.9, 3.10, 3.11.

I also tried to copy the DLLs to a common path like windows/system32 , the project root and the python root, and nothing.

What am I missing?

Thanks for your attention.

Could I share the Github file links?

It's awesome! I have tried to build the qmysql drivers too many times,I don't know why I have copy the builded driver files to mingw81_32\plugins\sqldrivers\ it still show me "Driver not loaded". Now I download your files, it worked XD. Thanks for your build! Could I share your Github file links to another website? Because I'm not sure share the links without consent is polite.

5.13.2 version MinGw 32-bit

Hi!
I tried this version (in the title) but I faced a problem, the QMYSQL not loaded. Is there anything special with this version? Because I saw this: "32-Bit (since there is no 32-Bit MySQL server version 8.0, bundled with libmysql 5.7)"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.