Hello,
Is there a proper way to retrieve a class using its name other than going through the _decl_class_registry dictionary of declarative_base ?
I'm using the Joined Table Inheritance and would like to enable users to query specific subtypes.
ie: if I have the following structure:
Base = declarative_base()
class Sample(Base):
bla
class Tissue(Sample):
bla
class DNA(Sample):
bla
I would like to build a query using 'DNA' as class type...
session.query('DNA').all()
But this doesn't work so the solution I found is the following:
session.query(Base._decl_class_registry['DNA'])
Is this the only way to go or is there a cleaner way to obtain a class based on its String name ?
Thanks !