cpython/Doc/includes/sqlite3/md5func.py

12 lines
231 B
Python
Raw Normal View History

2007-08-15 11:28:01 -03:00
import sqlite3
import md5
def md5sum(t):
return md5.md5(t).hexdigest()
con = sqlite3.connect(":memory:")
con.create_function("md5", 1, md5sum)
cur = con.cursor()
cur.execute("select md5(?)", ("foo",))
print cur.fetchone()[0]