I have an application that may be left running for extended periods of time. It uses a SQLite database via QSqlDatabase and various other QtSQL classes (QSQLTableModel, QSqlQuery, etc, depending on where in the program it is used). The problem is that once I call open() on the database, it remains open until I explicitly close it, which is not until the program exits. Since this means the SQLite file is held open, this causes problems with things like backup programs that don't back up open files, or potentially services like dropbox (haven't tested that one thoroughly) that try to sync files between different computers.
Ideally, what I'd have is a system where you set up the connection, and then it automatically opens/closes the connection when needed (i.e. when doing a SELECT, INSERT, UPDATE, etc). With my app, this would generally only be for a) periodic updates or b) in direct response to user input, so most of the time the connection could remain closed. To the best of my knowledge (correct me if I am wrong), this is not possible with the existing QSqlDatabase/ QSQLITE database driver classes. So, assuming that I need to subclass something to implement such functionality: - Which class(es) will I need to subclass - QSqlDatabase? The SQLite Driver? Both? - Which functions specifically should I be looking at modifying? - How do classes like QSqlTableModel interact with the underlying QSqlDatabase as far as performing queries - would they know or care about the connection being closed at any point other than when it is explicitly doing a select or update/insert/delete? I do realize this could result in multiple open/close cycles in a rapid period of time (maybe I could reduce that by putting some sort of timer on the automatic close), but for the purposes of my application I don't see this as being an issue. Thanks! ----------------------------------------------- Israel Brewster Systems Analyst II 5245 Airport Industrial Rd Fairbanks, AK 99709 (907) 450-7293 ----------------------------------------------- [cid:e84a5d6b-1779-4d69-afc9-781595d38945@flyravn.com] [cid:0c00c43a-c113-4a29-bfba-108a7d1636eb@flyravn.com]
BEGIN:VCARD VERSION:3.0 N:Brewster;Israel;;; FN:Israel Brewster ORG:Frontier Flying Service;MIS TITLE:PC Support Tech II EMAIL;type=INTERNET;type=WORK;type=pref:isr...@frontierflying.com TEL;type=WORK;type=pref:907-450-7293 item1.ADR;type=WORK;type=pref:;;5245 Airport Industrial Wy;Fairbanks;AK;99701; item1.X-ABADR:us CATEGORIES:General X-ABUID:36305438-95EA-4410-91AB-45D16CABCDDC\:ABPerson END:VCARD
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest