Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Driver Not Loaded SQLITE
Forum Updated to NodeBB v4.3 + New Features

Driver Not Loaded SQLITE

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
4 Posts 2 Posters 1.8k Views
  • 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.
  • Dan3460D Offline
    Dan3460D Offline
    Dan3460
    wrote on last edited by
    #1

    It has been more than a year that i have not use QT. My old computer died so i have a fresh installation of QT. I was refreshing my programming memory and tried to create a database with sqlite, but when i tried to run i get the error "Driver not loaded". I remember having the same problem a couple of years ago but cannot remember how to solve.

    QSqlDatabase myDatabase;
        myDatabase.database("QSQLITE");
        myDatabase.setDatabaseName("email");
        qDebug() << "Here";
        qDebug() << QSqlDatabase::drivers();
        if(!myDatabase.open()){
            qDebug() << "Error";
            qDebug()<< myDatabase.lastError();
        }
    
    Here
    ("QSQLITE", "QMYSQL", "QMYSQL3", "QODBC", "QODBC3", "QPSQL", "QPSQL7")
    Error
    QSqlError("", "Driver not loaded", "Driver not loaded")
    
    1 Reply Last reply
    0
    • S Offline
      S Offline
      Stoyan
      wrote on last edited by
      #2

      I think you are using myDatabase.database("QSQLITE") wrongly.
      From documentation:

      [static] QSqlDatabase QSqlDatabase::database(const QString &connectionName = QLatin1String( defaultConnection ), bool open = true)
      Returns the database connection called connectionName. The database connection must have been previously added with addDatabase(). If open is true (the default) and the database connection is not already open it is opened now. If no connectionName is specified the default connection is used. If connectionName does not exist in the list of databases, an invalid connection is returned.
      

      The other things you can check are:

      • Do you have something like this in *.pro file:
      QT += sql
      
      • If your project is compiled in Release mode, do you have plugin in your application folder: sqldrivers/qsqlite.dll (this is for Windows).
      1 Reply Last reply
      0
      • Dan3460D Offline
        Dan3460D Offline
        Dan3460
        wrote on last edited by
        #3

        You are correct, i was using database wrong. It pays to put attention to the documentation.

        myDatabase = QSqlDatabase::addDatabase("SQLITE");
        
        

        Thanks

        S 1 Reply Last reply
        0
        • Dan3460D Dan3460

          You are correct, i was using database wrong. It pays to put attention to the documentation.

          myDatabase = QSqlDatabase::addDatabase("SQLITE");
          
          

          Thanks

          S Offline
          S Offline
          Stoyan
          wrote on last edited by
          #4

          @Dan3460
          In addDatabase() must be specified SQL driver and for SQLite it is "QSQLITE", not "SQLITE".

          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