Results 1 to 8 of 8

Thread: QSQLITE problem with DROP

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2012
    Posts
    4
    Qt products
    Qt4

    Default QSQLITE problem with DROP

    Hi to all,

    I have a problem with a db software that I create for my friend. The problem is the following:

    When I do:

    Qt Code:
    1. QSqlQuery *qry = new QSqlQuery();
    2.  
    3. qry->prepare("DROP TABLE Month");
    4.  
    5. if(!qry->exec()){
    6.  
    7. qDebug() << qry->lastError().text();
    8.  
    9. }
    To copy to clipboard, switch view to plain text mode 

    I get the following error during the application runtime:

    "database table is locked Unable to fetch row"

    How can I solve this problem? I try to Delete the table with sqlite_browser but after that I re-create the table Month with:

    Qt Code:
    1. QSqlQuery *qry1 = new QSqlQuery();
    2.  
    3. if(!qry1->exec("CREATE TABLE IF NOT EXISTS Month (Codice NUMERIC, Prodotto TEXT, Qta TEXT)"))
    4.  
    5. qDebug() << qry1->lastError().text();
    6.  
    7. delete qry1;
    To copy to clipboard, switch view to plain text mode 


    and try to DROP the table Month, I obtain the same error.

    My db is in qsqlite.


    Sorry for my bad english but I'm italian and I hope that we can understand my really bad english

    Thanks a lot in advance !!!!

  2. #2
    Join Date
    Jan 2008
    Posts
    107
    Thanks
    36
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QSQLITE problem with DROP

    Since SQLite databases are mere files... have you checked file permissions on it? (i.e. not read-only)

    Usually if a process has a lock on a sqlite database and crashes it locks it permanently. If that's the case I suggest dump and restore it to another file...

    Linux solution:
    Qt Code:
    1. echo ".dump" | sqlite old.db | sqlite new.db
    To copy to clipboard, switch view to plain text mode 

    HTH

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

    Default Re: QSQLITE problem with DROP

    If the directory containing the database cannot be written then Sqlite cannot create needed temporary files to track transactions and you get messages similar to this. On Windows writes will be blocked by default if you place the database in a subfolder of Program Files hierarchy.

Similar Threads

  1. problem with QSQLITE.
    By Con Nít in forum Qt Programming
    Replies: 1
    Last Post: 2nd August 2011, 09:20
  2. QSQLITE problem with FOREIGN KEY
    By kamilus in forum Qt Programming
    Replies: 6
    Last Post: 26th April 2011, 01:10
  3. Problem deploying qt application using qsqlite on Windows XP/7
    By anoraxis in forum Installation and Deployment
    Replies: 4
    Last Post: 8th April 2011, 14:18
  4. Replies: 1
    Last Post: 7th July 2008, 21:13
  5. QSqlite problem
    By dragon in forum Qt Programming
    Replies: 2
    Last Post: 11th April 2007, 03:02

Tags for this Thread

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.