We are using SQLALchemy solely for the purpose of converting DB-independent code to sql statements (through compile and explicit usage of dialect). We are not using the ORM in anyway, nor are we creating engines through create_engine.
I believe that using it this way does not make SQLA create any thread or db connection in the background. Is this true ?
SQLAlchemy does not spawn threads, and will do everything within the thread a particular operation is invoked.
The one place you can encounter synchronization-oriented quirks, even without spawning any threads, is in the pretty rare case that particular objects are garbage collected by Python’s GC cleanup thread. Such as if you worked with a
Connectionobject, didn’t close it, and then let it fall out of scope, if it happens to be garbage collected by the gc thread you might see the DBAPIconnection.rollback()method called in the GC, as SQLAlchemy cleans up connections when the garbage collector collects them. The solution to that issue, if the DBAPI is having issues with it, is to make sure you close out resources likeConnectionandSessionobjects proactively.