[pysqlite] [apsw] ReadOnlyError when closing read-only blobs?
Austin Bingham <[email protected]> Tue, 1 Sep 2009 15:09:59 +0200
| Newsgroups | gmane.comp.python.db.pysqlite.user |
|---|---|
| Message-ID | <[email protected]> |
I've found that Blob.close() throws a ReadOnlyError if I've previously
attempted to perform a write on that blob. I was surprised by this,
but I wanted to see if this is expected behavior.
Here's code that demonstrates the issue:
import apsw
sql = '''
CREATE TABLE IF NOT EXISTS data
(id INTEGER PRIMARY KEY NOT NULL,
data BLOB NOT NULL)'''
conn = apsw.Connection('test.db')
cur = conn.cursor()
cur.execute(sql)
cur.execute('INSERT INTO data VALUES(?,?)', (None, apsw.zeroblob(1000)))
rowid = conn.last_insert_rowid()
blob = conn.blobopen('main', 'data', 'data', rowid, False)
# Attempt a write
try:
blob.write('x' * 10)
except apsw.ReadOnlyError:
# expected
pass
# This throws ReadOnlyError unexpectedly
blob.close()
This is with version 3.6.16 on python 2.6.1.
Austin