Beispiel #1
0
def sa_column_type(model, column_name):
    sa_model = inspect_sa(model)
    col = sa_model.c.get(column_name)
    col_type = None
    if col is not None:
        col_type = type(col.type).__name__.lower()
    return col_type
Beispiel #2
0
def sa_relationships(model, relation_name=None, directions=[MANYTOONE]):
    # Find relationship (filter by name, do not filter if filter_name = None)
    res = []
    for r in inspect_sa(model).relationships:
        pass
        if relation_name is None:
            if r.direction in directions:
                res.append(r)
        elif relation_name.lower() == r.key.lower():
            res.append(r)

    return res
Beispiel #3
0
def sa_hybrids(model):
    return [
        item for item in inspect_sa(model).all_orm_descriptors
        if type(item) == hybrid_property
    ]
Beispiel #4
0
def sa_columns(model):
    mapper = inspect_sa(model)
    return mapper.attrs