I am looking for a way to introspect SQLAlchemy ORM classes/entities to determine the types and other constraints (like maximum lengths) of an entity's properties.
For example, if I have a declarative class:
class User(Base):
__tablename__ = "USER_TABLE"
id = sa.Column(sa.types.Integer, primary_key=True)
fullname = sa.Column(sa.types.String(100))
username = sa.Column(sa.types.String(20), nullable=False)
password = sa.Column(sa.types.String(20), nullable=False)
created_timestamp = sa.Column(sa.types.DateTime, nullable=False)
I would want to be able to find out that the 'fullname
' field should be a String with a maximum length of 100, and is nullable. And the 'created_timestamp
' field is a DateTime and is not nullable.