[storm] Error - Database is locked

Shaun McCance shaunm at gnome.org
Wed Mar 11 19:34:28 GMT 2009


On Tue, 2009-03-10 at 16:39 +0100, Christian Klinger wrote:
> Hello,
> 
> 
> i ve a problem with my zstorm-sqlite database.
> 
> i get these error. Anyone an idea howto deal with it.
> 
>     arzt = store.find(Arzt, (Arzt.anmeldename == unicode(login), 
> Arzt.status ==         unicode('aktiv'))).one()
>   File 
> "/opt/python-2.4.4/lib/python2.4/site-packages/storm-0.12-py2.4.egg/storm 
>         /store.py", line 1029, in one
>     result = self._store._connection.execute(select)
>   File 
> "/opt/artus/buildout-eggs/storm-0.12-py2.4.egg/storm/database.py", line 
> 2        01, in execute
>     raw_cursor = self._check_disconnect(
>   File 
> "/opt/artus/buildout-eggs/storm-0.12-py2.4.egg/storm/database.py", line 
> 3        17, in _check_disconnect
>     return function(*args, **kwargs)
>   File 
> "/opt/python-2.4.4/lib/python2.4/site-packages/storm-0.12-py2.4.egg/storm 
>         /databases/sqlite.py", line 153, in raw_execute
>     return Connection.raw_execute(self, statement, params)
>   File 
> "/opt/artus/buildout-eggs/storm-0.12-py2.4.egg/storm/database.py", line 
> 2        83, in raw_execute
> 

There's the obvious question of whether you have another
process or thread accessing the database at the same time.
Other than that, it's hard to pinpoint the problem without
seeing more.

But I can tell you about an sqlite locking problem I had
recently.  You might be running into the same problem.
Code that boils down to this can cause locking issues:

for result in store.find(...):
    modify_something()
    store.flush()

Bear in mind that flush could be called implicitly.

The problem is that Storm leaves the ResultSet open,
fetching results as you iterate over it.  This causes
any updates in that iterator to fail.

Not sure if this is the problem you're having, but it
seems like a pretty easy problem to run across.

--
Shaun





More information about the storm mailing list