我们从Python开源项目中,提取了以下1个代码示例,用于说明如何使用sqlalchemy.sql.expression.ColumnElement()。
def get_field_type(model, fieldname): """Helper which returns the SQLAlchemy type of the field. """ field = getattr(model, fieldname) if isinstance(field, ColumnElement): fieldtype = field.type else: if isinstance(field, AssociationProxy): field = field.remote_attr if hasattr(field, 'property'): prop = field.property if isinstance(prop, RelProperty): return None fieldtype = prop.columns[0].type else: return None return fieldtype