Results 1 to 6 of 6

Thread: QT & SQLite - driver not loaded

  1. #1
    Join Date
    Jul 2010
    Location
    Poland
    Posts
    184
    Thanks
    70
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QT & SQLite - driver not loaded

    Hello!

    I'm trying to read from SQLite database. I've wrote simple function:

    Qt Code:
    1. void MainWindow::odczytajBazeSQL()
    2. {
    3. QSqlDatabase::addDatabase("QSQLITE");
    4.  
    5. bdb.setDatabaseName("/test.db");
    6. bdb.open();
    7.  
    8. QSqlQueryModel *queryModel = new QSqlQueryModel;
    9. queryModel->setQuery("SELECT * FROM t1", bdb);
    10.  
    11. ui->tableView->setModel(queryModel);
    12. }
    To copy to clipboard, switch view to plain text mode 

    test.db is a simple database with one table t1. When I'm trying to read with code above I get error:

    Qt Code:
    1. QSqlDatabase: QSQLITE driver not loaded
    2. QSqlDatabase: available drivers:
    3. QSqlQuery::exec: database not open
    To copy to clipboard, switch view to plain text mode 

    Normally I'm using sqlite3 to create and use databases. What should I do to make it work?

    thanks in advance
    best regards
    Tomasz

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QT & SQLite - driver not loaded

    QSqlDatabase: available drivers:
    You don't seem to have any Qt sql drivers installed. Maybe you need to install some additional packages for your distribution.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    Tomasz (21st July 2010)

  4. #3
    Join Date
    Jul 2010
    Location
    Poland
    Posts
    184
    Thanks
    70
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QT & SQLite - driver not loaded

    I've copied compilled driver (it wasn't there), I've change my code to:

    Qt Code:
    1. QSqlDatabase bdb = QSqlDatabase::addDatabase("QSQLITE");
    2.  
    3. bdb.setDatabaseName("./test.db");
    4. ok = bdb.open();
    To copy to clipboard, switch view to plain text mode 

    and now It works fine,

    best regards
    Tomasz
    Last edited by Tomasz; 21st July 2010 at 09:30.

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QT & SQLite - driver not loaded

    Change your code to:
    Qt Code:
    1. QSqlDatabase bdb = QSqlDatabase::addDatabase("QSQLITE");
    2. bdb.setDatabaseName("/test.db");
    3. bdb.open();
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. The following user says thank you to wysota for this useful post:

    Tomasz (21st July 2010)

  7. #5
    Join Date
    Feb 2008
    Posts
    50
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT & SQLite - driver not loaded

    Hello all. As we are speaking about SQLITE driver i had a very stressful experience with that driver (4.6.2/4.6.3). I deployed over 100 copies of one program using latest sqlite driver. There was no problem anywhere... i put the dll file under the executable file in directory "sqldrivers".
    Only in some particular systems this new driver wasn`t loading... i was like O_o. I`m talking about 2% of all the systems.
    I`ve spent a lot of hours debugging remotely the machines and didn`t find a way to make it work. But i knew my old software worked on those machines before... then i switched to a sqlite dll from 4.4.0 and .. magically the driver was loaded!
    Apparently something in the driver changed but i couldn`t find time to investigate further.

    Edit: the machines were WinXP Pro SP3.
    Last edited by sadjoker; 22nd July 2010 at 17:23.

  8. #6
    Join Date
    Jun 2014
    Posts
    1
    Qt products
    Qt5 Qt/Embedded

    Thumbs up Re: QT & SQLite - driver not loaded

    Thank you!!!
    The advices really help a lot!!!

Similar Threads

  1. Help with QMYSQL driver for QT 4.4.0: driver not loaded
    By khikho in forum Installation and Deployment
    Replies: 4
    Last Post: 1st April 2011, 15:00
  2. Replies: 1
    Last Post: 24th April 2010, 03:43
  3. Driver not loaded
    By wirasto in forum Qt Programming
    Replies: 0
    Last Post: 23rd November 2009, 06:08
  4. Driver not loaded
    By rogerio in forum Installation and Deployment
    Replies: 8
    Last Post: 16th May 2009, 07:07
  5. SQlite driver not loaded error
    By ibergmark in forum Installation and Deployment
    Replies: 2
    Last Post: 17th March 2008, 01:09

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.