cs50/python-cs50

sqlite db is locked for all clients

kzidane opened this issue · 0 comments

When starting a transaction from > 1 clients, the database file appears to be locked for all clients, rather than all except one.

Steps to reproduce:

In terminal 1:

$ python3
>>> import cs50
>>> db = cs50.SQL('sqlite:///foo.db')
>>> db.execute('begin transaction')
>>> db.execute('update x set y = 1')

In terminal 2:

>>> import cs50
>>> db = cs50.SQL('sqlite:///foo.db')
>>> db.execute('begin transaction')
>>> db.execute('update x set y = 2')

In terminal 1:

>>> db.execute('commit')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/cs50/sql.py", line 21, in decorator
    return f(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/cs50/sql.py", line 388, in execute
    raise e
RuntimeError: database is locked

Same exception is raised in terminal 2.