Solved Manjaro mariadb driver not loaded
-
Hi to all,
I'm new to Qt and I get this error trying to connect to my Mariadb server
QSqlDatabase: test driver not loaded
QSqlDatabase: available driver: QTBASE QSQLITE QMYSQL QMYSQL3 QODBC ...I use Manjaro, and I installed QTCreator, mariadb-connector-c
I read also the tread for ARCH.
I added this line to my test.pro
QT += sqlQTPLUGIN += qsqlmysql
Is all corrected , any test unit I can look at ?
Thanks -
@saulos said in Manjaro mariadb driver not loaded:
QTPLUGIN += qsqlmysql
This is not needed.
You need to use 'QMYSQL' as database driver - please show us how you try to open the database. -
Hi thanks for the reply.
so I have to use
QTPLUGIN += QMYSQLI got the example for a book and converted to Mariadb
the code is :#include <QCoreApplication>
#include <QtSql/QSql>
#include <QtSql/QSqlDatabase>
#include <QtSql/QSqlQuery>
#include <QDebug>int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);QSqlDatabase db = QSqlDatabase::addDatabase("test"); db.setHostName("192.168.X.X"); db.setPort(3306); db.setDatabaseName(("test")); db.setUserName("----"); db.setPassword("----"); if(db.open()) { qDebug() << "Connesso"; } else { qDebug() << "Fallita connessione"; return 0; } return a.exec();
}
-
-
Thanks
Solved
changed
QSqlDatabase db = QSqlDatabase::addDatabase("test");
to
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");