On Tue, 2007-07-31 at 00:13 -0700, 7stud wrote: > On Jul 30, 6:25 pm, [EMAIL PROTECTED] wrote: > > 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') > > buffer() ?
Using buffer is not in itself wrong, as some DB-API modules, including sqlite3, do use buffer objects to encapsulate binary data. However, the encapsulation should be called in a portable way by using the standard Binary factory function: b = sqlite3.Binary(contents). What is wrong, though, is passing the filename into it instead of the contents. This is in addition to the wrong execute call and using the wrong version of the sqlite module, as I pointed out in my previous reply. -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list