Python sqlite3中保存二进制文件
# -*- coding: utf-8 -*-
"""
Created on Sun Nov 25 15:56:01 2012
@author: l
"""
import sqlite3
db = sqlite3.connect(r'c:\imageDB.db')
#fp=open(r'c:\title.jpg','rb')
#data=fp.read();
#fp.close()
cur=db.cursor()
#cur.execute('insert into cet_t values("title2.jpg",?)',(sqlite3.Binary(data),))
#db.commit()
cur.execute('select img from cet_t')
b = cur.fetchone()[0]
f=open('c:\\test2.jpg','wb')
f.write(b)
db.close()