How to connect Mariadb with Qt on Fedora

  • Hello , I'm using Fedora 29 , and trying to connect mariadb with qt but it's failing
    after using
    $ locate Trainingdb // the name of database
    it prints /var/lib/mysql/Trainingdb

    QSqlDatabase db = QSqlDatabase::database( "QSQLITE","Trainingdb");
    db.setHostName("localhost") ;

        QMessageBox::about(this,"sql", "Connected" );

    }else {

       QMessageBox::about(this,"sql","not Connected");
    if(QFile::exists("db")) {
        QString S = "good" ;
        qDebug() << S;
    }else {
        qDebug() << "  error ";
    QSqlQuery qrry(db);

    but when i use only
    QSqlDatabase db = QSqlDatabase::serDatabase( "QSQLITE") ;

    it connected but there are no tables or anything in this QSQLITE even i guess there is no QSqlite otherwise it came with qt , Thanks in advance

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Why are you trying to connect to a MariaDB server using the SQLite plugin ?

    You should be using the MySQL plugin.

Log in to reply
