Results 1 to 4 of 4

Thread: Weird bug with SQLite

  1. #1
    Join Date
    Feb 2009
    Location
    Russia, Siberia, Novosibirsk
    Posts
    11
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Weird bug with SQLite

    Hello peoples.
    I have very weird bug with my sqlite db. I can open database, i can write data to it, and can correctly close it, but when i'm trying to open this database again, it's empty. O_o
    When i perform "db.open()" it becomes clean... What can it be?

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Weird bug with SQLite

    Can you show us some code? (Maybe you create the database in RAM?)

  3. #3
    Join Date
    Feb 2009
    Location
    Russia, Siberia, Novosibirsk
    Posts
    11
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Weird bug with SQLite

    Qt Code:
    1. bool DBWorker::OpenDB() {
    2. db = QSqlDatabase::addDatabase("QSQLITE");
    3. db.setHostName("localhost");
    4. db.setDatabaseName("data");
    5. db.setUserName("maryjane");
    6.  
    7. if (db.open() == false) {
    8. qDebug() << "Error. Database not opened.";
    9. return false;
    10. }
    11.  
    12. ...
    13. QUERIES KINDA "CREATE TABLE ... IF NOT EXISTS"
    14. ...
    15.  
    16. return true;
    17. }
    18.  
    19. DBWorker::~DBWorker() {
    20. db.close()
    21. }
    To copy to clipboard, switch view to plain text mode 

    In other function i have inserting data. It's really inserting, 'cause when i'm closing application, db size are growing.
    So, when i'm performing this instruction at the next application start

    Qt Code:
    1. if (db.open() == false) {
    To copy to clipboard, switch view to plain text mode 

    db becomes clean.
    Sorry for my bad english.

  4. #4
    Join Date
    Feb 2009
    Location
    Russia, Siberia, Novosibirsk
    Posts
    11
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Weird bug with SQLite

    In debug i found this string:

    "QSqlDatabasePrivate::removeDatabase: connection 'qt_sql_default_connection' is still in use, all queries will cease to work."
    But i'm closing database. What's the problem?
    Last edited by RavenS; 28th March 2009 at 18:05.
    Sorry for my bad english.

Similar Threads

  1. Qt SQLite user functions
    By cevou in forum Qt Programming
    Replies: 1
    Last Post: 10th March 2009, 19:43
  2. sqlite version in Qt
    By janus in forum Newbie
    Replies: 4
    Last Post: 5th February 2009, 14:18
  3. Weird problem: multithread QT app kills my linux
    By Ishark in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 09:12
  4. SQLite
    By cyberboy in forum Installation and Deployment
    Replies: 1
    Last Post: 15th April 2008, 19:46
  5. sqlbrowser and sqlite
    By janus in forum Installation and Deployment
    Replies: 2
    Last Post: 31st March 2008, 14:59

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.