Hi,

I have converted a legacy program that has used a Microsoft Jet (Access) 
database. The program is written in Visual C++. It is an client-server MFC 
application that used OLE-DB interfaces to directly connect to the database. I 
have managed to write a drop-in replacement for all the OLE-DB data accessors, 
and now they all are sqlite3 interfaces. OK, this is the introduction.

Now, to the problem itself.

The program has a global object called g_session. It used to be an ATL 
CSession-derived class that instantiated an OLE-DB connection at the program 
startup and closed the connection at the program end. I have converted the 
class, so it contains a sqlite3* member that gets opened using sqlite3_open_v2 
at the program startup and closed using sqlite3_close at the end. As you can 
imagine, this global g_session object is used everywhere in the program for all 
the selects, updates, inserts and deletes.

The program is a multi-user program that runs across the network in Windows 
environment. The users constantly experience database lockout problems. I 
suspect that it is due to the fact that the sqlite* object that has been used 
for database updates still remains in the 'exclusive lock' mode even when the 
program is doing normal 'selects'.

I am thinking of converting the program, so that sqlite* objects are created at 
the beginning of each 'database operation' and destroyed straight away. As you 
can imagine, there are hundreds of lines of code that refer to the global 
g_session object, and the task would be time consuming. Therefore, before I 
proceed with the task, I wanted to ask what is the right way to use the 
sqlite3* object. Is it better to use a global or a local connection object? 
Will I add an overhead by opening and closing the database connection for each 
database operation?

Regards,
Andrew Cherednik
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to