我正在尝试使用pyodbc和python插入字典列表但是我收到以下错误:
TypeError: ('Params must be in a list, tuple, or Row', 'HY000')
我在Azure中托管了一个数据库,我需要在表中插入1800多行,如下例所示
kp = {'documents': [
{'id': '1', 'keyPhrases': ['sport', 'baseball', 'aliens']},
{'id': '2', 'keyPhrases': ['play', 'capacity', 'tired']},
{'id': '3', 'keyPhrases': ['international', 'balance', 'boring']}
]
lst = []
for x in kp['documents']:
for i in kp['keyPhrases']:
lst.append({'keyphrases': i, 'paragraph_id': x['id']})
cursor.fast_executemany = True
sql = 'INSERT INTO keyphrases2 (keyphrases, paragraph_id) VALUES (%
(keyphrases)s, %(paragraph_id)s'
cursor.executemany(sql, lst)