2024-06-28 20:54:34 发布
网友
我有一个Python列表,我想把它插入到PSQL数据库中。在
lsls = [[int1, int2, int3],[int4, int5, int6]]
我尝试过psycopg2模块的以下命令,但它不起作用:
第一个列表中的整数应添加到col1,第二个列表中的整数应添加到col2。在
你需要把你的列表转换过来。尝试list_by_rows = zip(*lsls),然后将其作为executemany()的参数。在
list_by_rows = zip(*lsls)
executemany()
有关executemany()如何工作的示例,请参见此处:
How can I use executemany to insert into MySQL a list of dictionaries in Python
你需要把你的列表转换过来。尝试
list_by_rows = zip(*lsls)
,然后将其作为executemany()
的参数。在有关executemany()如何工作的示例,请参见此处:
How can I use executemany to insert into MySQL a list of dictionaries in Python
相关问题 更多 >
编程相关推荐