I need to save an image file into sqlite database in python. I could not find a solution. How can I do it?
Thanks in advance.
write - cursor.execute('insert into File
(id, name, bin) values (?,?,?)', (id, name, sqlite3.Binary(file.read())))
read - file = cursor.execute('select bin from File where id=?', (id,)).fetchone()
if you need to return bin data in web app - return cStringIO.StringIO(file['bin'])