R
rustyhowell
I'm trying to store binary data in a sqlite database and call into the
db using pysqlite 3.
What I've got so far is this:
import sqlite
con = sqlite.connect(DB_PATH)
cur = con.cursor()
query = """create table t1(
ID INTEGER PRIMARY KEY,
data BLOB );"""
cur.execute(query)
con.commit()
b = buffer('/path/to/binary/file')
query = 'insert into table (ID,data) values (1,?);'
result = cur.execute(query,(b))
con.commit()
The error message I get is :
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.5/site-packages/sqlite/main.py", line 255, in
execute
self.rs = self.con.db.execute(SQL % parms)
TypeError: not all arguments converted during string formatting
I also read about using adapters, but I haven't found any clear info
on how to use them.
Does anyone have an example of storing binary data (image) in sqlite
using pysqlite?
db using pysqlite 3.
What I've got so far is this:
import sqlite
con = sqlite.connect(DB_PATH)
cur = con.cursor()
query = """create table t1(
ID INTEGER PRIMARY KEY,
data BLOB );"""
cur.execute(query)
con.commit()
b = buffer('/path/to/binary/file')
query = 'insert into table (ID,data) values (1,?);'
result = cur.execute(query,(b))
con.commit()
The error message I get is :
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.5/site-packages/sqlite/main.py", line 255, in
execute
self.rs = self.con.db.execute(SQL % parms)
TypeError: not all arguments converted during string formatting
I also read about using adapters, but I haven't found any clear info
on how to use them.
Does anyone have an example of storing binary data (image) in sqlite
using pysqlite?