コード例 #1
0
def test_update():
    x = {'a': 1, 'b': '2', 'c': 1223.4}
    sql, params = query_builder.update('foo', **x)
    assert sql == 'UPDATE `foo` SET `a`=%(_QB_a)s, `b`=%(_QB_b)s, `c`=%(_QB_c)s'
    assert params == {'_QB_a': 1, '_QB_b': '2', '_QB_c': 1223.4}
    assert database.escape_query(
        sql, params) == r"UPDATE `foo` SET `a`=1, `b`='2', `c`=1223.4"
コード例 #2
0
def update_data(table_name, conditions, **data):
    """
    :param data: Accepts list of dicts
    :param table_name: tablename in MEMSql
    :return:
    """
    if cache_state == 0: return True
    tablename = table_name
    #TODO Check if data is null (skip take is exceeded)
    sql, params = update(tablename,**data)
    sql_full = '{0} {1}'.format(sql, conditions)
    with get_connection() as conn:
             c = conn.execute(sql_full,**params)
             return c
コード例 #3
0
def test_update():
    x = { 'a': 1, 'b': '2', 'c': 1223.4 }
    sql, params = query_builder.update('foo', **x)
    assert sql == 'UPDATE `foo` SET `a`=%(_QB_a)s, `b`=%(_QB_b)s, `c`=%(_QB_c)s'
    assert params == { '_QB_a': 1, '_QB_b': '2', '_QB_c': 1223.4 }
    assert database.escape_query(sql, params) == r"UPDATE `foo` SET `a`=1, `b`='2', `c`=1223.4"