/ Published in: Python

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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()
Comments
