我这样一张Mysql数据表
先前使用Flask写了一个数据处理配置接口,第一次调用该接口传递指定参数,对指定列进行处理返回如下结果
但再次调用该接口处理其他列的时候,返回如下结果
如何返回如下结果?
该接口核心代码大致如下
# 获取数据值
datas = res[0] # ['FOL', 'FOL', 'FOL', 'FOL', 'FOL', 'FOL', 'FOL', 'FOL']
# 获取字段名
col = res[1] # Site
# 查询output_table数据表中存在的字段名
new_field = view_datasheet_field('output_table')
print(new_field)
if col in new_field:
# 执行插入sql语句
sql = f"INSERT INTO output_table ({col}) VALUES (%s)"
# sql = f"UPDATE output_table SET {col}=(%s);"
# 插入数据
for data in datas:
cursor.execute(sql, (data,))