Qt doesn't load any database drivers - mysql

I'm porting my project from qt4.8.4 on windows server 2003(32bit) to qt5.3.1 on win7(64bit), I build qt source statically, and build qsqlmysql dynamically, but my code can not load mysql qt driver. The error is like follows,
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers:()
My code is as follows,
db = QSqlDatabase::addDatabase("QMYSQL", "*****");
db.setHostName("*****");
db.setDatabaseName("*****");
db.setUserName("*****");
db.setPassword("*****");
When I search "QMYSQL" in registry, I get nothing, it seems qmysql driver is not registered.
Any ideas?

A default configuration will only give you sqlite support, maybe ODBC will be auto-detected on windows. You will need to specify sql support and possibly provide libs and include paths too. For example (using mardiadbclient for mysql):
Pre Qt 5.8:
-qt-sql-mysql -L E:\msys64\mingw64\lib -l mysqlclient -I E:\msys64\mingw64\include\mariadb
Post Qt 5.8:
-sql-mysql MYSQL_INCDIR=E:\msys64\mingw64\include\mariadb MYSQL_LIBDIR=E:\msys64\mingw64\lib MYSQL_LIBS="-l mysqlclient" -L
E:\msys64\mingw64\lib

in qt4.8.4, when you link qsqlmysql statically, you should write:
Q_IMPORT_PLUGIN(qsqlmysql)
but in qt5.3.1, the name changed, you should write the macro as following:
Q_IMPORT_PLUGIN(QMYSQLDriverPlugin)
That's why i always get a unresolved external... error. After change the name, i can link mysql successfully.

Related

While running oracle Goldengate for mysql version 19.1 getting warning--> !!! WARNING !!! --> libssl-2.17.0-stub.so

I am using oracle goldengate for mysql version 19.1. While login to mysql DB from ggsci I am getting below warning. I have checked file libssl-2.17.0-stub.so, this file is not
present in LD_LIBRARY_PATH also not present in my linux machine. Due to this warning login not happening hence extract is not starting. Also did set up environment variables like-
MYSQL_UNIX_PORT
MYSQL_HOME
OGG_MYSQL_OPT_SSL_CA
OGG_MYSQL_OPT_SSL_CERT
OGG_MYSQL_OPT_SSL_KEY
GGSCI > dblogin SOURCEDB DB#host:3306, USERID XXX PASSWORD XXXX
Getting below error-
!!! WARNING !!! --> libssl-2.17.0-stub.so
This is a stub library which can be used for linking only. It must not
be used as a runtime library. Please make sure this library is not found
in LD_LIBRARY_PATH.
Can someone please help me with this.
Can you follow the steps from this doc link, and install OpenSSL and set the PATH as needed:
Check out this topic:
6.4 Other Programs and Settings for MySQL
Doc link: https://docs.oracle.com/en/middleware/goldengate/core/19.1/installing/installing-mysql1.html#GUID-14BA87AB-194B-483C-AECF-151A31F4AFC1
Let us know if that resolves it.

Broken MySql driver for PySide2 on Windows?

I've been forced to try to port to PySide2 from PySide because I'm developing code (on Windows 7) used inside Maya and Maya 2017 has moved to PySide2.
PySide2 ships with Maya but only comes with the driver to talk to sqlite DBs. So I need to tell Qt about a new DIR that contains the MySql driver, like this:
from PySide2 import QtWidgets
QtWidgets.QApplication.addLibraryPath("C:\temp\plugins")
This DIR contains a sub sqldrivers DIR which contains the driver. This works- when I call QtSql.QSqlDatabase.drivers() the new one is there so I've got the right driver and it's being picked up.
However when I create a new DB and call open:
db = QtSql.QSqlDatabase.addDatabase("QMYSQL3")
db.setDatabaseName("my_db")
db.setHostName("host")
db.setUserName("user")
db.setPassword("password")
db.open()
the open command returns False and the DB is not accessible. I call:
db.lastError()
and get:
# Result: <PySide2.QtSql.QSqlError("", "Driver not loaded", "Driver not loaded") at 0x0000000075410C08> #
NB: we successfully did the exact same thing with the previous PySide version.
Other threads mention similar things and it turned out to be missing the actual libmysql.dll, which is the actual MySql DLL and can result in the same error if missing. However I definitely have this on my system and it's definitely in the PATH. It's actually the same file that is being successfully picked up through PySide. But the PySide2 driver just wont open a connection to the DB.
I suspect maybe a dodgy driver but wondered if anyone has any experience with this or any advice?
I had the same error, but with postgres.
I solved by placing the libpq.dll connector library next to my script.py.
Then for mysql it would be libmysql.dll.
In my case I had to build the libpq.dll from the source of postgres 9.6
It seems that with PySide2 it is not necessary to use:
QtWidgets.QApplication.addLibraryPath ("C: \ path_to\ plugins")
using:
print (PySide2.QtCore.QLibraryInfo.location (PySide2.QtCore.QLibraryInfo.PluginsPath)), I could see that the path was correct.
a greeting

xcode: Mysql connector library not work on iphone5 (armv7s) ,any solution?

I built my App using Mysql Connector/C to connect a remote Mysql database, its works fine on the simulator (no errors, no warnings) but when i try to run it on my device (iphone5) i got this error:
No architectures to compile for (ARCHS=armv7 armv7s, VALID_ARCHS=armv7 armv7s)
i tried -as in some answers- to change setting (Architectures - Build Active Architectures- Valid Architectures) but the error still, only when i change the setting (Architectures & Valid Architectures) to "armv6" its build without error but many warnings appears says:
warning: no rule to process file '(my App dir)/main.m' of type sourcecode.c.objc for architecture armv6
and also for all .m files, when i tried to start the App i got message:
Xcode cannot run using selected device
I know that the Connector library need to update , but are there any solution ?
your need compile the connector lib in xcode for iOS (armv6, armv7, armv7s, i386), then use lipo tool to combine output libs.
direct connect your mysql in app is not safe, a suggest way is setup a Apache+PHP+MySQL server, then on iPhone useing ASIHTTPRequest to connect your server.

Qt - Trying mysql driver

I followed this tutorial to compile mysql driver with VS2010 :
Qt - How to get|compile Mysql driver.
The compilation fails with the error : LNK1123: failure during conversion to COFF: file invalid or corrupt
I tried with with multiple versions of mysql and qt, i always get the same error.
Note: I am using Qt-4.8.4 and mysql-5.5.32-win32.
I would rebuild Qt from source, because you also need the SQL driver (not only the plugin).
The driver source is located under /src/sql/drivers/mysql
The plugin source is located under /src/plugins/sqldrivers
/src/sql/drivers/mysqldrivers.pri contains this:
contains(sql-drivers, all):sql-driver += psql mysql odbc oci tds db2 sqlite ibase
contains(sql-drivers, mysql):include($$PWD/mysql/qsql_mysql.pri)
So I think that you need to run configure with the options: -qt-sql-mysql and -plugin-sql-mysql before compiling Qt.
Recompile Qt
Open a Qt 4.8.4 Command Prompt
cd \qtdir
nmake distclean
configure -debug-and-release -platform win32-msvc2010 -mp -nomake examples -nomake demos -qt-sql-mysql -plugin-sql-mysql
nmake
You might need to point configure to the correct include/library directory for MySQL, by adding this options: -I "c:\path\to\mysql\include" and -L "c:\path\to\mysql\lib"

mysql qt in linux and windows

On a centos,
qt creator 1.2.1
qtsdk-2009.04
what step by step is needed to create mysql driver, in linux and in windows.
such that running following command gives an positive output
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("xxxxxxxxxx");
db.setDatabaseName("xxxxxxxdb");
db.setUserName("xxxxxxxxxxx");
db.setPassword("xxxxxxxxxxx");
bool ok = db.open();
Brgds,
kNish
I used to have PostgreSQL(8.3) driver compiled successfully.Following is the batch cmds to do the job(replace the path with yours).
cd D:\SoftwareSetup\Dev\Qt\2009.05\qt\src\plugins\sqldrivers\psql
D:\SoftwareSetup\Dev\Qt\2009.05\qt\bin\qmake “INCLUDEPATH+=D:\SoftwareSetup\Dev\PostgreSQL\8.3\include” “LIBS+=D:\SoftwareSetup\Dev\PostgreSQL\8.3\lib\libpq.lib” psql.pro
#”D:\SoftwareSetup\Dev\Microsoft Visual Studio 9.0\VC\bin\nmake”
“D:\SoftwareSetup\Dev\Qt\2009.05\mingw\bin\mingw32-make”
pause
If you use VC compiler,use nmake to get it compiled,
and I also referenced to following two links to find out library dependency:
http://lists.trolltech.com/qt-interest/2006-11/thread00265-0.html
http://doc.trolltech.com/4.6/sql-driver.html#how-to-build-the-qdts-plugin-on-windows
This page from Nokia Qt doc may be helpful on *nix(and Windows):
http://doc.qt.nokia.com/4.6/sql-driver.html#supported-databases