Where is the best place for registering custom SQLite functions?

2 views
Skip to first unread message

Adam Dziendziel

unread,
Jul 28, 2008, 1:46:10 AM7/28/08
to sqlalchemy
Hello,

Where is the best place for registering custom SQLite functions? It
should be done when a connection to the database is created. Where is
a proper place if I'm using SQLAlchemy?

Best regards,
Adam

Michael Bayer

unread,
Jul 28, 2008, 10:06:34 AM7/28/08
to sqlal...@googlegroups.com

you can use the "creator" argument to create_engine(), or you could
use the "pool events" API. PoolListener is here: http://www.sqlalchemy.org/docs/04/sqlalchemy_interfaces.html#docstrings_sqlalchemy.interfaces_PoolListener

usage would be along the lines of:

engine = create_engine(...)

class MyListener(PoolListener):
def connect(self, dbapi_con, con_record):
...setup things on dbapi_con....

engine.pool.add_listener(MyListener())

Adam Dziendziel

unread,
Jul 28, 2008, 2:43:16 PM7/28/08
to sqlalchemy
Thank you!
Reply all
Reply to author
Forward
0 new messages