使用python在oracle db单列表中插入字符串数组

wljmcqd8  于 2022-12-22  发布在  Oracle
关注(0)|答案(1)|浏览(133)
json_object = []
for i in range(len(df_dictionary)):
    json_object.append(json.dumps(df_dictionary[i], indent=4, default=str))

如何将包含数组(40)中json字符串列表的json_object插入到具有单列和40行字符串的DB中?

cmd = "INSERT INTO STG_ETL_RBT(PAYLOAD) VALUES (:1)"
cursor.executemany(cmd, json_object)

如何根据上述要求更改sql语句?

pxyaymoc

pxyaymoc1#

cmd = "INSERT INTO STG_ETL_RBT(PAYLOAD) VALUES (:1)"
cursor.executemany(cmd, [(i,) for i in json_object])

[(i,) for i in json_object]在参数中添加此代码即可完成此工作👍

相关问题