I am seeking some advice on best practice regarding setting up
sqlite_pragma across applications.
I have the following code which I currently put in each and every module
across my applications, wherever such module uses SQLAlchemy.
> @sqlalchemy.event.listens_for(sqlalchemy.engine.Engine, "connect")
> def set_sqlite_pragma(dbapi_connection, connection_record):
> cursor = dbapi_connection.cursor()
> cursor.execute("PRAGMA foreign_keys=ON")
> cursor.close()
>
It does the job, but is there a way to centralize this effort so I can have
this snippet only one place for all modules?
I'm not sure if simply factoring the above snippet out and making it a
separate module in itself will do the job, because each module will use
independent sqlalchemy module, right? So setting ModuleA's sqlite_pragma
doesn't have any effect on ModuleB's sqlite_pragma. Am I right here?
Hopefully some pros can give me some simple but practice advice here. Many
thanks.
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.