Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSQLITE driver not loaded
Forum Updated to NodeBB v4.3 + New Features

QSQLITE driver not loaded

Scheduled Pinned Locked Moved General and Desktop
sqliteqt 5.4.2
3 Posts 2 Posters 3.2k 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.
  • E Offline
    E Offline
    ExorcistInc
    wrote on last edited by ExorcistInc
    #1

    Hi!
    I have problem with deployed application. It could not create and access sqlite database, with next messages in debugger:

    QSqlDatabase: QSQLITE driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
    bool AnisStorage::setupDb() Error: "Driver not loaded Driver not loaded"
    QSqlQuery::exec: database not open
    

    And here is code example:

        m_dbConnection = QSqlDatabase::addDatabase("QSQLITE");
        // m_dbName = D:/QtBuilds/kvant-cpm-release/cpmStorage.sqlite
        m_dbConnection.setDatabaseName(m_dbName); 
        const bool isDbOpened = m_dbConnection.open();
    
        if(!isDbOpened) {
            qDebug() << Q_FUNC_INFO << "Error:" << m_dbConnection.lastError().text();
            return false;
        }
    

    I am using Qt 5.4.2, MinGW 4.9.2 and have "sqldrivers" dir with Qt SQL drivers in application folder.

    How to fix this?)

    1 Reply Last reply
    0
    • CharlieGC Offline
      CharlieGC Offline
      CharlieG
      wrote on last edited by
      #2

      Hello

      I have the same problem. I use Qt 5.5 on Archlinux.

      This my codes:
      storage.h:

      #ifndef STORAGE_H
      #define STORAGE_H
      
      #include <QObject>
      #include <QSqlDatabase>
      #include <QDebug>
      #include <QSqlError>
      #include <QSqlDriver>
      
      class QString;
      
      
      
      class Storage : public QObject
      {
          Q_OBJECT
      public:
          explicit Storage(QObject *parent = 0);
          Q_INVOKABLE bool open();
      
      signals:
      
      public slots:
      
      private:
          QSqlDatabase* m_sqlDatabase;
      
      };
      
      #endif // STORAGE_H
      

      storage.cpp:

      #include "storage.h"
      
      Storage::Storage(QObject *parent) : QObject(parent)
      {
          m_sqlDatabase = new QSqlDatabase();
      
      }
      
      bool Storage::open()
      {
      
          qDebug() << QSqlDatabase::drivers();
          qDebug() << QSqlDatabase::isDriverAvailable("QSQLITE3");
          m_sqlDatabase->addDatabase("QSQLITE3", "SQLITE");
          m_sqlDatabase->setDatabaseName("myBdd");
      
          if (m_sqlDatabase->open()){
              return true;
          }
      
          else{
              qDebug() << m_sqlDatabase->lastError();
              return false;
          }
      }
      

      and my .pro

      unix:LIBS += -lpq -L"/usr/lib/qt/plugins/sqldrivers"
      

      As ExorcistInc, I have this messages with qDebug() :
      ("QIBASE", "QSQLITE", "QSQLITE3", "QMYSQL", "QMYSQL3", "QODBC", "QODBC3", "QPSQL", "QPSQL7")
      true
      QSqlError("", "Driver not loaded", "Driver not loaded")

      Have I include other file ?

      Thank you in advance

      Charlie

      1 Reply Last reply
      0
      • E Offline
        E Offline
        ExorcistInc
        wrote on last edited by
        #3

        Well, I figured out, that in my case it was stupid mistake of using MSVC windeployqt with MinGW compiled app.

        1 Reply Last reply
        0

        • Login

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