Page 1 of 2 12 LastLast
Results 1 to 20 of 22

Thread: SQLite make problems

  1. #1
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default SQLite make problems

    Hello everybody,
    QT 4.1.3
    SQlite 3.0
    OS: WINXP

    I am able to connect to my sqlite DB and i am also able to show all values on my listView..
    If i try to insert a new row i get thie ERROR: "database is locked unable to fetch row"..
    I think this database has a problem, but i need this database, there are all data i need
    I am also not able to change values on my QTableView
    I can doble click a row on my listview, i can write something there but the values desaper from the listiew
    if i delete everything from this database and try to insert a new row or change a value directly on the listview it workssss!!!!
    Have somebody a idea what is wrong?

    Thanks forwarding
    Think DigitalGasoline

  2. #2
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: SQLite make problems

    Quote Originally Posted by raphaelf View Post
    Hello everybody,
    QT 4.1.3
    if i delete everything from this database and try to insert a new row or change a value directly on the listview it workssss!!!!
    Have somebody a idea what is wrong?

    Thanks forwarding

    If you show the model source piece from this table people here can help... to solve problem...

    If your DB can open on http://sqlitebrowser.sourceforge.net/ or http://sourceforge.net/projects/qtexcel-xslt/ sqlite2 or 3 the db is not broken.... readonly?

  3. #3
    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: SQLite make problems

    Maybe you locked the database (or row) from within your application somewhere not knowing about it? Are you inside of a transaction? Did you run any query that may have rendered the database read-only? Do you have write permissions for the file containing the database?

  4. #4
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: SQLite make problems

    hi everibody,

    I can say that i have permissions and i tryed follow:

    My Database has 257 rows..
    If i delete some rows directly with sqlite3.exe and start my app again, so i am able to insert some rows, but after inserting some rows i get this ERROR again.

    BUT I AM ABLE TO INSERT NEW ROWS direct with sqlite3.exe, but why not via QT

    Have somebody a idea??
    Think DigitalGasoline

  5. #5
    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: SQLite make problems

    Do you have free space on the disk where the database is located?

  6. #6
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: SQLite make problems

    Hi wysota,

    Yes a have some GBs free space..

    Have something to do with this ?:
    http://www.sqlite.org/lockingv3.html

    I am searching a solution since 4 weeks
    Think DigitalGasoline

  7. #7
    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: SQLite make problems

    Could you show us your code used to manipulate the database?

  8. #8
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: SQLite make problems

    Of course:

    Have you a idea?
    Qt Code:
    1. // Connect to the SQLITE Database
    2. bool MainWindow::connectToDB()
    3. {
    4. //Um PostgreSQL zu vervenden muss der QPSQL Treiber QPSQL verwendet werden.
    5. QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    6. db.setDatabaseName("LernIT.db");
    7. }
    8.  
    9. // QSQLTableModel to show and manipulate data on the sqlite database
    10. void MainWindow::showWords()
    11. {
    12. ui.description_le->setDisabled(true);
    13. setWhite();
    14. ui.l1_le->clear();
    15. ui.l2_le->clear();
    16. ui.plural_le->clear();
    17. ui.description_le->clear();
    18.  
    19. model->setTable("words_tbl");
    20. model->setEditStrategy(QSqlTableModel::OnFieldChange);
    21. model->select();
    22. //model->removeColumn(0); // don't show the ID
    23. model->setHeaderData(1, Qt::Horizontal, tr("Deutsch"));
    24. model->setHeaderData(2, Qt::Horizontal, tr("Portuguiesisch"));
    25.  
    26. ui.tableView->setModel(model);
    27. ui.tableView->setColumnHidden(0, true);
    28. ui.tableView->sortByColumn(1);
    29. ui.tableView->show();
    30. }
    31.  
    32.  
    33. // I am using this Script to insert new rows to the database:
    34. QSqlQuery insert;
    35. insert.prepare("insert into words_tbl (language1, language2, plural, description) values ('"
    36. + ui.l1_le->text() + "', '" + ui.l2_le->text() + "','" + ui.plural_le->text() + "', '" + ui.description_le->text() + "')");
    37. if( ! insert.exec() ) {
    38. QMessageBox::information(this,"LernIT",insert.lastError().text());
    39. return;}
    40.  
    41. //To select some data i am using this script:
    42. QString random;
    43. QSqlQuery count("SELECT words_id FROM words_tbl WHERE rowid>=random() % (SELECT max(words_id)+1 FROM words_tbl) LIMIT 1;");
    44.  
    45. while(count.next())
    46. {
    47. random = count.value(0).toString();
    48. }
    To copy to clipboard, switch view to plain text mode 
    Attached Files Attached Files
    Last edited by jacek; 6th June 2007 at 22:09. Reason: wrapped too long line
    Think DigitalGasoline

  9. #9
    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: SQLite make problems

    What's the point of using "prepare" here if you don't make any bindings afterwards?

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: SQLite make problems


  11. #11
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: SQLite make problems

    Hi everybody,
    I found out that if i dont call this part, i am able to insert how much rows with qt i want:
    Qt Code:
    1. void MainWindow::showWords()
    2. {
    3.  
    4. ui.description_le->setDisabled(true);
    5. setWhite();
    6. ui.l1_le->clear();
    7. ui.l2_le->clear();
    8. ui.plural_le->clear();
    9. ui.description_le->clear();
    10.  
    11. model->setTable("words_tbl");
    12. model->setEditStrategy(QSqlTableModel::OnFieldChange);
    13. model->select();
    14. //model->removeColumn(0); // don't show the ID
    15. model->setHeaderData(1, Qt::Horizontal, tr("Deutsch"));
    16. model->setHeaderData(2, Qt::Horizontal, tr("Portuguiesisch"));
    17.  
    18. ui.tableView->setModel(model);
    19. ui.tableView->setColumnHidden(0, true);
    20. ui.tableView->sortByColumn(1);
    21. ui.tableView->show();
    22.  
    23. }
    To copy to clipboard, switch view to plain text mode 

    So the QSQLTableModel makes problem.. and i am not able to update values on it..

    Have somebody now a idea?
    Last edited by raphaelf; 7th June 2007 at 08:53.
    Think DigitalGasoline

  12. #12
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: SQLite make problems

    Could be that QSQLTableModel is not working corect with sqlite3?
    Because witch ms sql and postgre it works perfect
    Think DigitalGasoline

  13. #13
    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: SQLite make problems

    The problem is with SQLite, not with Qt.

  14. #14
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: SQLite make problems

    hi wysota, ok i see..

    So i will have to change to postgree again

    Is there no solution for work with sqltablemodel and sqlite3?
    Think DigitalGasoline

  15. #15
    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: SQLite make problems

    Update to a newer version.

  16. #16
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: SQLite make problems

    Hi wysota i have downloaded and tryed sqlite 3.3.17 (newest version)
    and i am also not able to change my values on the qsqltablemodel
    Think DigitalGasoline

  17. #17
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: SQLite make problems

    Quote Originally Posted by raphaelf View Post
    So the QSQLTableModel makes problem.. and i am not able to update values on it..

    Have somebody now a idea?
    Maybe this will help: http://trolltech.com/developer/task-...ntry&id=128671

  18. #18
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: SQLite make problems

    Hi Jacek,

    I have insert two new lines, is that correct, because i have same problem:
    Qt Code:
    1. model->setTable("words_tbl");
    2. model->setEditStrategy(QSqlTableModel::OnFieldChange);
    3. model->select();
    4. //Should this line solve the problem??
    5. while (model->canFetchMore()){
    6. model->fetchMore();}
    7. //model->removeColumn(0); // don't show the ID
    8. model->setHeaderData(1, Qt::Horizontal, tr("Deutsch"));
    9. model->setHeaderData(2, Qt::Horizontal, tr("Portuguiesisch"));
    10.  
    11. ui.tableView->setModel(model);
    12. ui.tableView->setColumnHidden(0, true);
    13. ui.tableView->sortByColumn(1);
    14. ui.tableView->show();
    To copy to clipboard, switch view to plain text mode 
    Think DigitalGasoline

  19. #19
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: SQLite make problems

    Quote Originally Posted by raphaelf View Post
    I have insert two new lines, is that correct, because i have same problem:
    If you have the same problem as the one discussed on qt-interest, then it means you can't have more than one query object at once.

    Try executing that loop before you create QSqlQuery and create only one instance of that class.

  20. #20
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: SQLite make problems

    Hi ..

    I am using before insert a new row like that
    Qt Code:
    1. void MainWindow::insert()
    2. {
    3. model->setTable("words_tbl");
    4. while (model->canFetchMore()){
    5. model->fetchMore();}
    6. model->setEditStrategy(QSqlTableModel::OnFieldChange);
    7. model->select();
    8.  
    9. //model->removeColumn(0); // don't show the ID
    10. model->setHeaderData(1, Qt::Horizontal, tr("Deutsch"));
    11. model->setHeaderData(2, Qt::Horizontal, tr("Portuguiesisch"));
    12.  
    13. ui.tableView->setModel(model);
    14. ui.tableView->setColumnHidden(0, true);
    15. ui.tableView->sortByColumn(1);
    16. ui.tableView->show();
    17.  
    18. if ((ui.l1_le->text() == "")||(ui.l2_le->text() == ""))
    19. {
    20. QMessageBox::information(this,"LernIT","Please fill field Deutsch and Portuguiesisch");
    21. return;}
    22.  
    23.  
    24. if (ui.switch_cb->currentIndex() == 0)
    25. {
    26. /*
    27. QSqlQuery insert;
    28. insert.prepare("insert into words_tbl (language1, language2, plural, description) values ( :lang1, :lang2, :plural, :desc );" );
    29. insert.bindValue( ":lang1", ui.l1_le->text() );
    30. insert.bindValue( ":lang2", ui.l2_le->text() );
    31. insert.bindValue( ":plural", ui.plural_le->text() );
    32. insert.bindValue( ":desc", ui.description_le->text() );
    33. if( ! insert.exec() ) {
    34.   QMessageBox::information(this,"LernIT",insert.lastError().text());
    35.   ui.l1_le->setText("");
    36.   ui.l2_le->setText("");
    37.   ui.plural_le->setText("");
    38.   ui.description_le->setText("");
    39.   ui.l1_le->setFocus();
    40.   return;}
    41.   */
    42. QSqlRecord rec = model->record();
    43. rec.setValue("language1", ui.l1_le->text());
    44. rec.setValue("language2", ui.l2_le->text());
    45. rec.setValue("plural", ui.plural_le->text());
    46. rec.setValue("description", ui.description_le->text());
    47. model->insertRecord(-1, rec);
    48. .
    49. .
    50. .
    To copy to clipboard, switch view to plain text mode 

    Should i post my .cpp file?

    Please help me
    Think DigitalGasoline

Similar Threads

  1. QMake make install problems
    By cookiem in forum Qt Programming
    Replies: 12
    Last Post: 4th December 2008, 15:34
  2. SQLITE database problems
    By phoenix in forum Newbie
    Replies: 3
    Last Post: 30th April 2007, 21:38
  3. Window OS make distclean && qmake && make one line
    By patrik08 in forum General Programming
    Replies: 4
    Last Post: 22nd March 2007, 10:43
  4. Compiling with Qmake/Make
    By VireX in forum Newbie
    Replies: 25
    Last Post: 22nd February 2007, 05:57
  5. Qt4.1.4 make errors.
    By impeteperry in forum Installation and Deployment
    Replies: 11
    Last Post: 1st July 2006, 17:27

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.