В Python 2.7
import sqlite3
conn = sqlite3.connect(":memory:")
cur = conn.cursor()
cur.execute("create table test(v1 text, v2 int)")
for index in range(5):
cur.execute("insert into test values(\"python ###{index}\", {index})".format(index=index))
import re
def matchPattern(pattern, value):
return bool(re.match(pattern, value)) # return true or false
# creating the 'match' function.
conn.create_function("matchPattern", 2, matchPattern)
работает ...
i = cur.execute("select v1, v2 from test where matchPattern('python', v1)")
print i.fetchall()
# print -> ["python ### 1", 1), "python ### 2", 2), ..., ....]