class FooTable(Base):
Id = Column(BIGINT, primary_key=True)
name = Column(VARCHAR(256), nullable=False)
username = Column(VARCHAR(256), nullable=False)
state = Column(VARCHAR(100), nullable=False)
city = Column(VARCHAR(256), nullable=False)
zip = Column(VARCHAR(100), nullable=False)
我想打印出类 Column 的实例化参数。通常 - python 代码到字符串。例子:
for k, v in vars(FooTable).iteritems():
print k, get_class_attr(v)
>>> Id ["BIGINT", "primary_key=True"]
>>> name ["VARCHAR(256)", "nullable=False"]
...
我尝试了检查模块,但发现它不支持它: http ://docs.python.org/library/inspect.html#inspect.getmembers
感谢您提供任何信息