Python sqlalchemy.sql.expression 模块,ColumnElement() 实例源码

我们从Python开源项目中,提取了以下1个代码示例,用于说明如何使用sqlalchemy.sql.expression.ColumnElement()

项目:oa_qian    作者:sunqb    | 项目源码 | 文件源码
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