We are using sqlalchemy's autoload feature to do column mapping to prevent hardcoding in our code.
class users(Base):
__tablename__ = 'users'
__table_args__ = {
'autoload': True,
'mysql_engine': 'InnoDB',
'mysql_charset': 'utf8'
}
Is there a way to serialize or cache autoloaded metadata/orms so we don't have to go through the autoload process every time we need to reference our orm classes from other scripts/functions?
I have looked at beaker caching and pickle but haven't found a clear answer if it is possible or how to do it.
Ideally we run the autload mapping script only when we have committed changes to our database structure but reference a non-autoload/persistent/cached version of our database mapping from all other scripts/functions,
Any ideas?
What I am doing now is to pickle the metadata after running the reflection through a database connection (MySQL) and once a pickle is available use that pickled metadata to reflect on the schema with the metadata bound to an SQLite engine.
Any comments if this is alright (it works) or there is something I can improve?