Model / View update base
-
Good morning,
I'm exploring QT Python and PySide6
I have a problem understanding the Model / view
I study the Book example
[https://doc.qt.io/qtforpython-6/examples/example_sql_books.html](link url)
the table view works: the data displayed is modified but the sqlite database is not updated (I replaced the memory base with a disk base)
I thought I understood, by reading the documentation, that when the model was modified, the database was updated automatically.
Can you give me a start?
thanks in advance -
Glancing at the code, so far as I can see I would expect it to work for a file if you just replace
memory
with that. How did you specify the file (full path rather than relative would be advisable). Did you create it first or leave SQLite to create it on first access? -
Thank you for your interest.
I just changed these 2 lines...in createdb.pydb.setDatabaseName("D:/Do-asus_Data/Documents/prjPython/TestQT/books/test.db")
# db.setDatabaseName(":memory:")The file database does not exist at the start of the programme.
I left the year field by "enter" and "mouse click on another field". In no case has the database been updated.
The database test.db opened with DB Browser allows the year field of the book table to be updated. -
@SGaist
..and indeed the OP's Python-only SQL Books Example hasOnManualSubmit
and nosubmit...()
...@dw06
This is not your fault! Because the example usedmemory
I guess no one noticed it never actually wrote back to the database!
Go look up the submit stuff in the docs and either make it one of the submit-as-you-move or do asubmitAll()
somewhere. -