Peng Yu
unread,Mar 10, 2020, 2:53:43 PM3/10/20Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to python...@googlegroups.com
Hi,
I have the following python code to write something to a sqlar file.
import apsw
conn = apsw.Connection(sys.argv[1])
c = conn.cursor()
c.execute('''
CREATE TABLE IF NOT EXISTS sqlar(
name TEXT PRIMARY KEY
, mode INT
, mtime INT
, sz INT
, data BLOB)
''')
import zlib
data = sys.stdin.buffer.read()
c.execute('REPLACE INTO sqlar VALUES(?, ?, ?, ?, ?)', [sys.argv[2], 0,
0, len(data), zlib.compress(data)])
But the problem is when multiple processes are trying to write to the
same database file, I got the following error. What is the correct way
to change the code so that it will not raise an exception but write to
the same database when other write operations are finished?
File "xxx.py", line 28, in <module>
c.execute('REPLACE INTO sqlar VALUES(?, ?, ?, ?, ?)',
[sys.argv[2], 0, 0, len(data), zlib.compress(data)])
File "src/cursor.c", line 236, in resetcursor
apsw.BusyError: BusyError: database is locked
--
Regards,
Peng