Beispiel #1
0
def build_insert(table_name, attributes):
    sql = "INSERT INTO %s" %(table_name)
    column_str = u""
    value_str = u""
    for index, (key, value) in enumerate(attributes.items()):
        if index > 0:
            column_str += u","
            value_str += u","
        column_str += key
        value_str += value_to_sql_str(value)
    sql = sql + u"(%s) VALUES(%s)" %(column_str, value_str)
    return sql
Beispiel #2
0
def build_insert(table_name, attributes):
    sql = "INSERT INTO %s" % (table_name)
    column_str = u""
    value_str = u""
    for index, (key, value) in enumerate(attributes.items()):
        if index > 0:
            column_str += u","
            value_str += u","
        column_str += key
        value_str += value_to_sql_str(value)
    sql = sql + u"(%s) VALUES(%s)" % (column_str, value_str)
    return sql
def build_update(table_name, condition, attributes):
    sql = u"UPDATE %s SET " %(table_name)    
    set_str = u""
    for index, (key, value) in enumerate(attributes.items()):
        if index > 0:
            set_str += u","
        set_str += key + u"=" + value_to_sql_str(value)

    query_str = build_query(condition)
    if query_str:
        query_str = u" WHERE " + query_str
    else:
        query_str = u""
    sql = sql + set_str + query_str
    return sql
Beispiel #4
0
def build_update(table_name, condition, attributes):
    sql = u"UPDATE %s SET " %(table_name)    
    set_str = u""
    for index, (key, value) in enumerate(attributes.items()):
        if index > 0:
            set_str += u","
        set_str += key + u"=" + value_to_sql_str(value)

    query_str = build_query(condition)
    if query_str:
        query_str = u" WHERE " + query_str
    else:
        query_str = u""
    sql = sql + set_str + query_str
    return sql