I am using sqlalchemy.orm and defining my table objects like so (trimmed down for brievety):
class my_table(Base):
__tablename__ = 'my_data'
__table_args__ = { 'schema': self.db_schema }
foo = Column(String, nullable=False)
@orm.reconstructor
def __init__(self, schema):
self.db_schema = schema
I want to be able to pass variables into the creation of this class like the db_schema variable above. The docs seem to imply the @orm.reconstructor decorator is used to do this but I can't figure out how to go about this approach.
My example above complains:
NameError: name 'self' is not defined
This class is defined in a library and the data I want to feed it during creation is pulled from a combination of command line arguments to main() and values pulled from a config file.