diff --git a/pandasql/sqldf.py b/pandasql/sqldf.py index e25398a..52a05c9 100644 --- a/pandasql/sqldf.py +++ b/pandasql/sqldf.py @@ -90,11 +90,18 @@ def conn(self): def _init_connection(self, conn): if self.engine.name == 'postgresql': conn.execute('set search_path to pg_temp') + elif self.engine.name == 'sqlite': + conn.connection.connection.create_function("REGEXP", 2, regex) def _set_text_factory(self, dbapi_con, connection_record): dbapi_con.text_factory = str +def regex(expr, item): + reg = re.compile(expr) + return reg.match(item) is not None + + def get_outer_frame_variables(): """ Get a dict of local and global variables of the first outer frame from another file. """ cur_filename = inspect.getframeinfo(inspect.currentframe()).filename