This has also been posted here: http://stackoverflow.com/questions/15950375/sqlalchemy-introspection-of-relationships, shoulda asked here first.
I have a use case for modelling data in a SQL schema rather than through defining SQLAlchemy objects. However, i require a way to construct the corresponding SQLAlchemy objects automatically from the SQL schema. Currently i have: from sqlalchemy import MetaData from sqlalchemy.ext.declarative import declarative_base meta = MetaData(bind=your_engine) meta.reflect() # get the table which we would like to represent as a Python object table = meta.tables['your_table_name'] # define the object which we will use as the base class base = declarative_base() # create db object MyObject = type(str(table.fullname), (base,), {'__table__': table}) however, the relationships between objects are not created. Any ideas how to go about doing this? Thanks! -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.