I'm using Django ORM layer outdoors of Django. The project is really a web application utilizing a cusotm in-house built framework.
Now, I'd no problems to setup Django ORM to operate stand alone, but I'm a tiny bit concerned about connection management. I've read Using only DB part of Django at SO which is correct that Django does some kind of special connection handling at the start and also the finish of every request. From django/db/__init__.py:
# Register an event that closes the database connection # when a Django request is finished. def close_connection(**kwargs): for conn in connections.all(): conn.close() signals.request_finished.connect(close_connection) # Register an event that resets connection.queries # when a Django request is started. def reset_queries(**kwargs): for conn in connections.all(): conn.queries =  signals.request_started.connect(reset_queries) # Register an event that rolls back the connections # when a Django request has an exception. def _rollback_on_exception(**kwargs): from django.db import transaction for conn in connections: try: transaction.rollback_unless_managed(using=conn) except DatabaseError: pass signals.got_request_exception.connect(_rollback_on_exception)
What problems can one encounter basically skip this connection management? (I've not a way to connect individuals signals into my framework easily)
It is dependent in your use situation. All these functions make a move specific, which might affect you.
If this sounds like a lengthy-running process and you've got DEBUG on, you will need to totally reset the queries or it'll keep all of the queries you've run in memory.
Should you spawn plenty of threads, connect with the DB once in early stages in every thread, by leaving the threads running, you'll should also close the connections when you are done while using DB, or you might hit your DB's connection limit.
You probably have no need for _rollback_on_exception - I am presuming you've your intended transaction behavior setup inside the relevant code itself.