Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Behind the Scenes
  3. Wiki Discussion
  4. How to connect Mariadb with Qt on Fedora

How to connect Mariadb with Qt on Fedora

Scheduled Pinned Locked Moved Unsolved Wiki Discussion
2 Posts 2 Posters 1.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MostafaEzzat
    wrote on last edited by MostafaEzzat
    #1

    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") ;
    db.setUserName("root");
    db.setPassword("mostafa");
    db.setDatabaseName("/var/lib/mysql");

    if(db.open()){
        QMessageBox::about(this,"sql", "Connected" );
    

    }else {

          qDebug() << db.lastError().text();
       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

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved