Ejemplo n.º 1
0
async def qshield_aggregator(*, t, group_col, agg_col, func, tk, **kw):
    table = None
    if t is None:
        raise APIValueError('t', message='t is None')
    else:
        table = table_model(t)

    if group_col is None:
        raise APIValueError('group_col', message='group collum is None')

    if agg_col is None:
        raise APIValueError('agg_col', message='aggregation collum is None')

    if func is None:
        raise APIValueError('func', message='aggregation function is None')

    if tk is None:
        raise APIValueError('tk', message='tk is None')

    res = await table.aggregator(g_c=group_col,
                                 a_c=agg_col,
                                 func=func,
                                 tk=tk,
                                 **kw)
    return data_res_format(data=res)
Ejemplo n.º 2
0
async def qshield_selector(*, t, st, tk, **kw):
    table = None
    if t is None:
        raise APIValueError('t', message='t is None')
    else:
        table = table_model(t)

    if st is None:
        raise APIValueError('st', message='st is None')

    if tk is None:
        raise APIValueError('tk', message='tk is None')

    res = await table.selector(st=st, tk=tk, **kw)
    return data_res_format(data=res)
Ejemplo n.º 3
0
async def qshield_query(*, st, p, tk, **kw):
    if st is None:
        raise APIValueError('st', message='st is None')

    if p is None:
        raise APIValueError('p', message='p is None')

    if tk is None:
        raise APIValueError('tk', message='tk is None')

    table_identifiers = extract_tables(st)
    if table_identifiers is None:
        raise APIValueError('st',
                            message=r"cannot extract tables from '%s'" % st)
    else:
        logging.info('found target tables: %s' % ', '.join(table_identifiers))
    tables = []
    for i in table_identifiers:
        tables.append(table_model(i))

    res = await Tables.sql_exe(tables=tables, st=st, p=p, tk=tk, **kw)
    return data_res_format(data=res)
Ejemplo n.º 4
0
async def qshield_joiner(*, t1, t2, st, mode, tk, **kw):
    table1 = None
    if t1 is None:
        raise APIValueError('t1', message='t1 is None')
    else:
        table1 = table_model(t1)

    table2 = None
    if t2 is None:
        raise APIValueError('t2', message='t2 is None')
    else:
        table2 = table_model(t2)

    if st is None:
        raise APIValueError('st', message='st is None')

    if mode is None:
        raise APIValueError('mode', message='mode is None')

    if tk is None:
        raise APIValueError('tk', message='tk is None')

    res = await table1.joiner(table2=table2, st=st, mode=mode, tk=tk, **kw)
    return data_res_format(data=res)