Exemplo n.º 1
0
def complex_select(table, columns=None, clause=None,
                   group=None, having=None, order=None):
    sel = simple_select(table, columns=columns, clause=clause)
    if group:
        sel += ' GROUP BY %s' % handle_fieldlist(group)
    if having:
        sel += ' HAVING %s' % having
    if order:
        sel += ' ORDER BY %s' % handle_fieldlist(order)
    return sel
Exemplo n.º 2
0
def simple_select(table=None, columns=None, clause=None):
    if columns is not None:
        if type(columns) != str:
            cols = handle_fieldlist(list(columns))
        else:
            cols = columns
    else:
        cols = '*'
    sel = 'select %s' % cols
    if table is not None:
        sel += ' from %s' % table
    if clause is not None:
        sel += ' where %s' % clause
    return sel
Exemplo n.º 3
0
def make_tuple(alist):
    return '(%s)' % handle_fieldlist(alist)
Exemplo n.º 4
0
def _set_vals_(a_dict):
    return handle_fieldlist([_set_eq_(k,v) for k,v in a_dict.items()])