Results 1 to 3 of 3

Thread: SQLite Out of Memory error

  1. #1
    Join Date
    Apr 2013
    Posts
    8
    Qt products
    Qt4 Qt5
    Platforms
    Windows
    Thanks
    1

    Default SQLite Out of Memory error

    Hi there! This is my first attempt to use QT and a portable db like SQLite.

    I've copied some code from a website to include it in my project, but every time I run it it displays the following message:

    "Error initializing database: Driver not loaded Driver not loaded"

    Here's my simple code:

    Qt Code:
    1. QSqlError initDb() {
    2.  
    3. QString dataDir = QDesktopServices::storageLocation(QDesktopServices::DesktopLocation);
    4. QDir dir(dataDir);
    5.  
    6. QString dbName = dir.filePath("gestion_stock.sqlite");
    7.  
    8. QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    9. db.setDatabaseName(dbName);
    10.  
    11. if (!db.open()) {
    12. return db.lastError();
    13. }
    14.  
    15. if (!q.exec(QLatin1String("create table if not exists producto(cod_fabrica varchar(20) primary key, "
    16. "cod_proveedor varchar(20), cod_local varchar(20), stock integer, "
    17. "stock_minimo integer, precio_compra decimal(5), precio_venta decimal(5), "
    18. "proveedor varchar(20), gondola varchar(5), estante integer)"))) {
    19. return q.lastError();
    20. }
    21.  
    22. return QSqlError();
    23. }
    To copy to clipboard, switch view to plain text mode 

    Don't mind the spanish names for the table and fields :P

    Any help will be appreciated!

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: SQLite Out of Memory error

    In order to use a Sqlite database your program must have access to the QSqlite plugin, which is not available to your program as the error message indicates. Running inside a normal IDE, where Qt is installed, this should be available. If this program is deployed then you must deploy the relevant plugins (sqldrivers folder) along with the Qt libraries.

    BTW: Why do you think
    "Error initializing database: Driver not loaded Driver not loaded"
    has anything to do with your thread title?
    SQLite Out of Memory error

  3. #3
    Join Date
    Apr 2013
    Posts
    8
    Qt products
    Qt4 Qt5
    Platforms
    Windows
    Thanks
    1

    Default Re: SQLite Out of Memory error

    I forgot to change that, at first it said "Out of memory: sqlite something" then it changed to driver not loaded.

    I have no idea how to do that, I'm running QtCreator.

    If I build the "Books Demonstration" example, which uses SQLite, it works just fine.

Similar Threads

  1. Sqlite Memory Use
    By drave in forum Newbie
    Replies: 8
    Last Post: 4th June 2010, 18:33
  2. Loading and saving in-memory SQLITE databases
    By miraks in forum Qt Programming
    Replies: 10
    Last Post: 27th April 2010, 21:24
  3. OUT OF MEMORY - Error while working with sqlite
    By Askar in forum Qt Programming
    Replies: 1
    Last Post: 27th November 2009, 23:54
  4. How can I send a SQLite :memory: database connection ?
    By georgep in forum Qt Programming
    Replies: 4
    Last Post: 20th July 2009, 12:07
  5. The Sqlite Error In Run!
    By alphaboy in forum Installation and Deployment
    Replies: 1
    Last Post: 19th November 2007, 14:45

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
  •  
Qt is a trademark of The Qt Company.