Results 1 to 3 of 3

Thread: data not being retained in sqlite DB

  1. #1
    Join Date
    Jun 2008
    Location
    Canada
    Posts
    10
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question data not being retained in sqlite DB

    Hello,

    Strange problem occuring. I have a simple QTableView displaying an sqlite table. I can change the data in the table and the changes are sent to the database, but as soon as I exit out of the application and I look at the database table again, the data that was added/changed is not there , but while the app was running I could see the data with a separate db viewing utility.

    Qt Code:
    1.  
    2. model->setTable(tableName);
    3. model->setEditStrategy(QSqlTableModel::OnManualSubmit);
    4. model->setRelation(18, QSqlRelation("Category", "mCategoryID", "mCategoryName"));
    5.  
    6. model->select();
    7.  
    8. m_pMusicTableView->setModel(model);
    9. m_pMusicTableView->hideColumn(0);
    10.  
    11. m_pMusicTableView->show();
    12.  
    13. ...
    14.  
    15. void DlgLibraryEditor::submit()
    16. {
    17. model->database().transaction();
    18. if (model->submitAll()) {
    19. model->database().commit();
    20. } else {
    21. model->database().rollback();
    22. QMessageBox::warning(this, tr("Library Manager"),
    23. tr("The database reported an error: %1")
    24. .arg(model->lastError().text()));
    25. }
    26. }
    To copy to clipboard, switch view to plain text mode 

    any insight greatly appreciated.

    Thanks,
    Johnny

  2. #2
    Join Date
    Mar 2008
    Posts
    141
    Thanks
    10
    Thanked 9 Times in 9 Posts

    Default Re: data not being retained in sqlite DB

    Hi,

    is there something like a sqlite journal file created? Then the data is stored temp due to a looked database. You should try to log the db errors. And I am not sure if the relationalmodel works at all because sqlite does not support primary keys.

  3. #3
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: data not being retained in sqlite DB

    Quote Originally Posted by janus View Post
    Hi,

    is there something like a sqlite journal file created? Then the data is stored temp due to a looked database. You should try to log the db errors. And I am not sure if the relationalmodel works at all because sqlite does not support primary keys.
    You can make the relation model work by imlementing primary keys' functionality with triggers.
    I'm a rebel in the S.D.G.

Similar Threads

  1. Replies: 4
    Last Post: 19th October 2007, 20:47
  2. Data model
    By steg90 in forum Qt Programming
    Replies: 3
    Last Post: 17th September 2007, 13:14
  3. speed of setdata - lots of items in treeview
    By Big Duck in forum Qt Programming
    Replies: 4
    Last Post: 6th July 2006, 13:53
  4. How to convert binary data to hexadecimal data
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 8th March 2006, 17:17
  5. Replies: 16
    Last Post: 7th March 2006, 16:57

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.