@summary: 适用于mysql, oracle数据库时间需要to_date 处理(TODO) --------- @param table: @param data: 表数据 json格式 @param condition: where 条件 --------- @result:
(table, data, condition)
| 2151 | |
| 2152 | |
| 2153 | def 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 | |
| 2181 | def make_batch_sql( |
no test coverage detected