Qt-interest Archive, April 2008
QSqlDatabase problem with QSQLITE driver.
Message 1 in thread
QSqlDatabase has been a royal pain no matter what driver I'm
using...I've had problems with MySQL, I've had problems with ODBC and
now up for grabs is SQLITE.
The problem with the SQlite driver is as follows: I can't close the
database!
I went as far as to completely reduce things to Qt API code only. No
subclassing, nothing.
1. Open my SQlite database using QSqlDatabase
2. Create a treeview with a QSqlQueryModel and a simple select statement
Both the treeview and model are stock QT classes, no subclassing.
When I now close the application, this is what happens when I call
QSqlDatabase::close()
QSqlError(-1, "Error closing database", "Unable to close due to
unfinalised statements")
So what am I supposed to do here? This is preventing me from using
sqlite because when the database is not properly closed, changes that
are made to it via update or insert statements can be lost.
Close for the database is called at the very end in main() after
application.exec() returns to try to ensure that all GUI windows, etc.
have been closed.
Thanks,
Stephan
--
[ signature omitted ]
Message 2 in thread
On Mon, 2008-04-21 at 08:30 +1000, Bill KING wrote:
> Shot in the dark here, but have close/clear'd any sql statements you
> have used, or descoped them?
> It looks like you have an sql statement still open somewhere from a
> quick look at the sqlite code.
Yep I know that is the case. However, I have no control over the query.
I'm simply creating a QSqlQueryModel, giving it my SQL query string and
assigning it to a view. I would expect it to handle everything else as
necessary internally without me needing to worry about it.
If I need to track every single SQL Query myself then I'm better off
interfacing with SQlite myself directly using the native API.
To me, the whole point of the SQL classes like QT has them is that I
just tell them what I want and leave the internal implementation and
worries up to them...if I can't do that then what's the point?
Thanks,
Stephan
--
[ signature omitted ]