Comment 8 for bug 1889851

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

As loaded by python:
0x00007ffff2dd4460 0x00007ffff2e0304e Yes (*) /lib/x86_64-linux-gnu/libQt5Sql.so.5

I was trying to get a different POV on the same lib, removing python out of the picture.

Install mysql and create a DB.

$ apt install mysql-server
$ systemctl start mysql
$ systemctl status mysql
$ mysql -u root
mysql> CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'user_password';
mysql> CREATE DATABASE test;
mysql> GRANT ALL PRIVILEGES ON test.* TO 'newuser'@'localhost';
mysql> USE test;
mysql> CREATE TABLE testtable (id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY);

Test Program:

# cat mysqlqt.pro
######################################################################
# Automatically generated by qmake (3.1) Tue Aug 4 12:46:45 2020
######################################################################

TEMPLATE = app
TARGET = mysqlqt
INCLUDEPATH += .
INCLUDEPATH += /usr/include/x86_64-linux-gnu/qt5
INCLUDEPATH += /usr/include/x86_64-linux-gnu/qt5/QtCore
INCLUDEPATH += /usr/include/x86_64-linux-gnu/qt5/QtGui
INCLUDEPATH += /usr/include/x86_64-linux-gnu/qt5/QtWidgets

QT += core gui sql
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

# The following define makes your compiler warn you if you use any
# feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0

# Input
SOURCES += mysqlqt.cpp

# cat mysqlqt.cpp
#include <QApplication>
#include <QPushButton>
#include <QSqlDatabase>

int main()
{
    QStringList drivers = QSqlDatabase::drivers();
    for(int i=0 ; i < drivers.length() ; i++) {
        qDebug("driver: %s", qUtf8Printable(drivers[i]));
    }

    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    db.setHostName("localhost");
    db.setDatabaseName("test");
    db.setUserName("newuser");
    db.setPassword("user_password");
    bool ok = db.open();

    qDebug("ok %i isopen %i isvalid %i", ok, db.isOpen(), db.isValid());
    qDebug("db-driver %s", qUtf8Printable(db.driverName()));

    qDebug("# start tables");
    QStringList tables = db.tables();
    for(int i=0 ; i < tables.length() ; i++) {
        qDebug("table: %s", qUtf8Printable(tables[i]));
    }
    qDebug("# end tables");

    return ok;
}

$ ./mysqlqt
driver: QSQLITE
driver: QMYSQL
driver: QMYSQL3
ok 1 isopen 1 isvalid 1
db-driver QMYSQL
# start tables
table: testtable
# end tables

So the QMYSQL isn't generally disfunctional since this update, it must be related to something more specific in the python wrapping of it.