Linked Questions

Popular Questions

SQLAlchemy introspection

Asked by At

What I am trying to do is to get from SqlAlchemy entity definition all it's Column()'s, determine their types and constraints, to be able to pre-validate, convert data and display custom forms to user.

How can I introspect it?


class Person(Base):
        Represents Person
    __tablename__ = 'person'

    # Columns
    id = Column(String(8), primary_key=True, default=uid_gen)
    title = Column(String(512), nullable=False)
    birth_date = Column(DateTime, nullable=False)

I want to get this id, title, birth date, determine their restrictions (such as title is string and max length is 512 or birth_date is datetime etc)

Thank you

Related Questions