Re: "database is locked" on first commit?
Mike <[email protected]>
| Newsgroups | gmane.comp.python.db.pysqlite.user |
|---|---|
| Message-ID | <[email protected]> |
Dennis Lee Bieber wrote: > On Fri, 19 Oct 2007 00:18:42 -0400, Mike > <[email protected]> declaimed the following > in gmane.comp.python.db.pysqlite.user: > > >> I'm having a "database is locked" problem with pysqlite. >> >> My python script creates several threads, and creates a database >> connection in each one. The first query to run that requires a commit >> fails and produces a "database is locked" error. I'm sure no other >> queries/connections/programs/etc are modifying my database file, and >> > > Doesn't matter if they are modifying or not -- as long as you have > an "uncommitted" /read query/ in one thread, you can't commit in another > thread. Commit requires an exclusive lock on the file, so ALL OTHER > connections/cursors/queries (ie, any other open transactions) MUST > commit/rollback/close. > > Remember, the specifications for Python's db-api are that > connections are NOT "auto-commit". > The way I understood it was that only queries that modified the database required a commit (a read would have no changes and therefore no need to commit the "transaction"). For what its worth, I am using isolation_level=None which apparently auto-commits all queries, and I still have the problem. I might be misunderstanding something.