I use SQLAlchemy at work and it does the job really fine. Now I am thinking about best practices.
For now, I create a module holding all the SQLA stuff :
my_model
|__ __init__.py
|__ _config.py <<<<< contains LOGIN, HOST, and a MetaData instance
|__ table1.py <<<<< contains the class, the model and the mapper for table1
|__ table2.py <<<<< contains the class, the model and the mapper for table2
[...]
Now, I really don't know if it's the best way to do it. I would like to load the classes with a fine granularity and be sure to create one connection only with the db, etc.
Here, all the classes are separated, but all import _config and I am wondering if it's a good thing.
What's more, I would like to be able to create subclasses of the model classes that could be stored independently without messing up with the mapper every time. How can I do that ?
For now I just put them in the same file and I have to create another mapper, but the first mapper is still called every time. The same would go if I'd have to import the parent class because the mapper is triggered at import. If I don't use the class to access data, isn't it overheat to map it each time ?
I'd like to avoid using Elixir too, please.