我试图将数据插入到从API获取的数据库中。我以前使用过这个,没有问题,也看不出有什么变化使它停止工作。除“id”、“乘数”和“价格”外,所有字段均为文本字段,其中第一个字段由postgres处理
我已经确保了格式占位符的数量映射了字段的数量,并且查询应该是正确的,所以我看不出问题出在哪里
对于类似问题的其他答案提到了混合字符串格式,但这里的情况并非如此。
我的代码:
cur.execute("""INSERT INTO "public"."main_page_product" ("id","collection_name","description",
"multiplier","dimension","feat1","feat10","feat2","feat3",
"feat4","feat5","feat6","feat7","feat8","feat9","image_url",
"price","short_name","sku","meta_name")VALUES (nextval('catalogue_product_id_seq'::regclass),%s,%s,
'2.2',%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)""",
(temp1['name'], temp1['short_description'], temp1['dimension'],
temp1['feat1'], temp1['feat2'], temp1['feat3'], temp1['feat4'],
temp1['feat5'], temp1['feat6'], temp1['feat7'], temp1['feat8'],
temp1['feat9'], temp1['feat10'], finurl, temp1['price'],
temp1['short_name'], temp1['sku'], temp1['meta_title']))
TypeError:在字符串格式化过程中并非所有参数都已转换
列名和参数之间不匹配:
相关问题 更多 >
编程相关推荐