Question

I'm writing an application with a GUI frontend (GTK) and an SQLite backend. When something is changed via the GUI, I want the change to show up in the GUI if and only if it completed successfully in the DB.

  • Is watching the return code from sqlite3_step for SQLITE_ERROR sufficient to ensure that I don't give false feedback to the user?

  • If not, are there other steps, such as callbacks or triggers, that would provide additional reliability?

  • Is there any way to detect ALL changes to the database, rather than just ones from the program's own connection, so that I could reflect changes to its content in the GUI dynamically?

Was it helpful?

Solution

Besides exception handling... You should reselect the data from the db that the user did commit by clicking on the save button. That way you know for sure that the user sees the right data.

OTHER TIPS

If I understand correctly you are doing a GUI application that modifies information in a SQLite db.

  • Not really, you might get SQLITE_BUSY if you have threads; SQLITE_INTERNAL; etc. Check SQLite documentation. Instead of asking for SQLITE_ERROR you could do something like:

SQLITE_OK or SQLITE_DONE depending on what you are doing.

if (ret != SQLITE_OK || ret != SQLITE_DONE)
    //then this is an error.
  • Don't know in what language are you coding, but I did an abstraction of SQLite in C here. You might find it interesting.

  • Use sqlite3_trace()

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top