Author: dmeyer
Date: Wed Aug 15 11:15:58 2007
New Revision: 2775
Log:
add regexp support in select
Modified:
trunk/base/src/db.py
Modified: trunk/base/src/db.py
==============================================================================
--- trunk/base/src/db.py (original)
+++ trunk/base/src/db.py Wed Aug 15 11:15:58 2007
@@ -151,7 +151,7 @@
"""
def __init__(self, operator, operand):
operator = operator.lower()
- assert(operator in ("=", "!=", "<", "<=", ">", ">=", "in", "not in",
"range", "like"))
+ assert(operator in ("=", "!=", "<", "<=", ">", ">=", "in", "not in",
"range", "like", "regexp"))
if operator in ("in", "not in", "range"):
assert(isinstance(operand, (list, tuple)))
if operator == "range":
@@ -182,6 +182,9 @@
copy_reg.pickle(ObjectRow, _pickle_ObjectRow, _unpickle_ObjectRow)
+def _regexp(expr, item):
+ r = re.compile(unicode(expr))
+ return r.match(item) is not None
class Database:
def __init__(self, dbfile = None):
@@ -199,6 +202,10 @@
def _open_db(self):
self._db = sqlite.connect(self._dbfile)
+
+ # Create the function "regexp" for the REGEXP operator of SQLite
+ self._db.create_function("regexp", 2, _regexp)
+
self._cursor = self._db.cursor()
self._cursor.execute("PRAGMA synchronous=OFF")
#self._cursor.execute("PRAGMA temp_store=MEMORY")
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog