Revision: 9896
Updated Code
at November 28, 2008 06:54 by deepdown
Updated Code
from pysqlite2 import dbapi2 as sqlite try: from sqlite import encode, decode except ImportError: import base64 sqlite.encode = base64.encodestring sqlite.decode = base64.decodestring else: sqlite.encode = encode sqlite.decode = decode imagedata = open('myfile.jpg', "rb").read() con = sqlite.connect("mydbfile") cur = con.cursor() cur.execute('INSERT INTO image(binarydata) VALUES (?)', (sqlite.encode(sqlite.Binary(imagedata)),)) con.commit() con.close()
Revision: 9895
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at November 28, 2008 06:19 by deepdown
Initial Code
from pysqlite2 import dbapi2 as sqlite imagedata = open('myfile.jpg', "rb").read() con = sqlite.connect("mydbfile") cur = con.cursor() cur.execute('INSERT INTO image(binarydata) VALUES (?)', (sqlite.Binary(imagedata),)) con.commit() con.close()
Initial URL
Initial Description
Initial Title
SQLite 3 insert binary image data with Python
Initial Tags
image, python
Initial Language
Python