MCPcopy Create free account
hub / github.com/Boris-code/feapder / make_update_sql

Function make_update_sql

feapder/utils/tools.py:2153–2178  ·  view source on GitHub ↗

@summary: 适用于mysql, oracle数据库时间需要to_date 处理(TODO) --------- @param table: @param data: 表数据 json格式 @param condition: where 条件 --------- @result:

(table, data, condition)

Source from the content-addressed store, hash-verified

2151
2152
2153def make_update_sql(table, data, condition):
2154 """
2155 @summary: 适用于mysql, oracle数据库时间需要to_date 处理(TODO)
2156 ---------
2157 @param table:
2158 @param data: 表数据 json格式
2159 @param condition: where 条件
2160 ---------
2161 @result:
2162 """
2163 key_values = []
2164
2165 for key, value in data.items():
2166 value = format_sql_value(value)
2167 if isinstance(value, str):
2168 key_values.append("`{}`={}".format(key, repr(value)))
2169 elif value is None:
2170 key_values.append("`{}`={}".format(key, "null"))
2171 else:
2172 key_values.append("`{}`={}".format(key, value))
2173
2174 key_values = ", ".join(key_values)
2175
2176 sql = "update `{table}` set {key_values} where {condition}"
2177 sql = sql.format(table=table, key_values=key_values, condition=condition)
2178 return sql
2179
2180
2181def make_batch_sql(

Callers 1

update_smartMethod · 0.90

Calls 2

format_sql_valueFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected