define a regexp function in sqlite

This commit is contained in:
Brian S. Stephan 2010-10-28 23:52:06 -05:00
parent 8fbd58e2c6
commit 487e997a55
1 changed files with 6 additions and 0 deletions

View File

@ -49,6 +49,12 @@ class Module(object):
self.conn = sqlite3.connect(dbfile)
self.conn.row_factory = sqlite3.Row
# setup regexp function in sqlite
def regexp(expr, item):
reg = re.compile(expr)
return reg.match(item) is not None
self.conn.create_function('REGEXP', 2, regexp)
# set up database for this module
self.db_init()