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 !


-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/wL8psJb1Jp4J.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to