1

I have an instance of a SQLAlchemy model and am trying to determine the types that the columns accept. Some of the columns attributes are None at the time I need to determine

class User(Base):
    __tablename__ = "user"
    id = Column(Integer, primary_key=True)
    login = Column(String())

Here is an pseudo code example of what I am trying to do.

user = User()
if type(inspect(user).get_property(id)) == Integer: 
   print "The id column expects Integers"

How do I turn this pseudo code into real code? Thanks!

Jakobovski
  • 3,203
  • 1
  • 31
  • 38
  • possible duplicate of [SQLAlchemy introspect column type with inheritance](http://stackoverflow.com/questions/11632513/sqlalchemy-introspect-column-type-with-inheritance) – Denis Otkidach Feb 02 '15 at 14:46

1 Answers1

0
isinstance(type(user).id.property.columns[0].type, Integer)
Denis Otkidach
  • 32,032
  • 8
  • 79
  • 100