I'm using Django to nicely display stats etc from an Oracle database that I only have/want read access to. Because the database has composite primary keys I'm not using Django's ORM layer and I'm using SQLAlchemy instead. The only installed apps I have are my own, and of the MIDDLEWARE_CLASSES
I'm only using CommonMiddleware
.
Based on this I have a single app accessing the database and working well. I put my sqlalchemy engine, session and orm.mapper all in models.py
then in my views.py
I just import the session and the classes that have been mapped.
However now I want to make a second app and obviously I should move the stuff in models.py
somewhere more generic so that it applies to the whole project, not just one app.
Where should I put it? Should I write some kind of very simple session middleware? Or is there some file that is only executed once when the server starts? Since I never write to the database, should I try and make all requests belong to the same session?
Should I just make random file in the project base like connect.py
and import it into the settings file?
Currently I am using the built-in server but I will be looking to use probably apache + mod_wsgi at some point.