memsql/common/query_builder.py
def simple_expression(joiner=', ', **fields):
    """ Build a simple expression ready to be added onto another query.

    >>> simple_expression(joiner=' AND ', name='bob', role='admin')
    "`name`=%(_QB_name)s AND `name`=%(_QB_role)s", { '_QB_name': 'bob', '_QB_role': 'admin' }
    """
    expression, params = [], {}

    for field_name, value in sorted(fields.items(), key=lambda kv: kv[0]):
        key = '_QB_%s' % field_name
        expression.append('`%s`=%%(%s)s' % (field_name, key))
        params[key] = value

    return joiner.join(expression), params
def simple_expression(joiner=', ', **fields):
    """ Build a simple expression ready to be added onto another query.

    >>> simple_expression(joiner=' AND ', name='bob', role='admin')
    "`name`=%(_QB_name)s AND `name`=%(_QB_role)s", { '_QB_name': 'bob', '_QB_role': 'admin' }
    """
    expression, params = [], {}

    for field_name, value in sorted(fields.items(), key=lambda kv: kv[0]):
        key = '_QB_%s' % field_name
        expression.append('`%s`=%%(%s)s' % (field_name, key))
        params[key] = value

    return joiner.join(expression), params
def simple_expression ( joiner = ', ' , * * fields ) : expression , params = [ ] , { } for field_name , value in sorted ( fields . items ( ) , key = lambda kv : kv [ 0 ] ) : key = '_QB_%s' % field_name expression . append ( '`%s`=%%(%s)s' % ( field_name , key ) ) params [ key ] = value return joiner . join ( expression ) , params
Build a simple expression ready to be added onto another query.

    >>> simple_expression(joiner=' AND ', name='bob', role='admin')
    "`name`=%(_QB_name)s AND `name`=%(_QB_role)s", { '_QB_name': 'bob', '_QB_role': 'admin' }
Build a simple expression ready to be added onto another query .