SQLite Regexp

111 views
Skip to first unread message

Simon Roadkill

unread,
Jun 23, 2007, 2:51:55 PM6/23/07
to sqlalchemy
Hello,
My application needs to run against Oracle and SQLite. I'd like to
have a query that uses a regexp in a select statement. For Oracle this
is fine, as it supports regular expressions natively. For raw SQLite I
can do:

connection.create_function("regexp", 2, regexp)

where regexp is defined as:

def regexp(expr, item):
r = re.compile(expr)
return r.match(item) is not None

If I create an SQLAlchemy engine, and then create a connection object
I can no longer use the create_function to build the regexp:

db = create_engine(database)
connection = db.connect()
connection.create_function("regexp", 2, self.regexp)

results in "'Connection' object has no attribute 'create_function'"

Is it possible to access the underlying SQLite connection, and use
that to create my regexp function?
Cheers
Simon

Michael Bayer

unread,
Jun 24, 2007, 12:25:14 AM6/24/07
to sqlal...@googlegroups.com

connection.connection

http://www.sqlalchemy.org/docs/
sqlalchemy_engine.html#docstrings_sqlalchemy.engine_Connection


Reply all
Reply to author
Forward
0 new messages