pyodbc 从列表中插入
pyodbc INSERT INTO from a list
我正在尝试使用列表作为值的来源将数据插入到 Access mdb 文件中。
cursor.execute("select * from Components")
cursor.executemany("""
INSERT INTO Components
([Database Number],Description, [Warehouse Code],[Supplier Code], Usage, Major1, Minor1)
VALUES (?,?,?,?,?,?,?)
"""), input_list
cursor.commit()
我收到错误 "TypeError: function takes exactly 2 arguments (1 given)"。错误指的是行 """), input_list
我做错了什么?预先感谢您的帮助。
这是 input_list
的印刷品
['7', '1/2" PVC 90° Elbow', '406-005', 'SUP2', 'Y', 'PVC FS', 'PVC FS']
['7', '3/4" PVC 90° Elbow', '406-007', 'SUP2', 'Y', 'PVC FS', 'PVC FS']
['7', '1" PVC 90° Elbow', '406-010', 'SUP2', 'Y', 'PVC FS', 'PVC FS']
['7', '1.25" PVC 90° Elbow', '406-012', 'SUP2', 'Y', 'PVC FS', 'PVC FS']
['7', '1.5" PVC 90° Elbow', '406-015', 'SUP2', 'Y', 'PVC FS', 'PVC FS']
['7', '2" PVC 90° Elbow', '406-020', 'SUP2', 'Y', 'PVC FS', 'PVC FS']
我明白了。 cursor.executemany 下的最后一行应为:
""", input_list)
我把右括号放错地方了
我正在尝试使用列表作为值的来源将数据插入到 Access mdb 文件中。
cursor.execute("select * from Components")
cursor.executemany("""
INSERT INTO Components
([Database Number],Description, [Warehouse Code],[Supplier Code], Usage, Major1, Minor1)
VALUES (?,?,?,?,?,?,?)
"""), input_list
cursor.commit()
我收到错误 "TypeError: function takes exactly 2 arguments (1 given)"。错误指的是行 """), input_list
我做错了什么?预先感谢您的帮助。
这是 input_list
的印刷品['7', '1/2" PVC 90° Elbow', '406-005', 'SUP2', 'Y', 'PVC FS', 'PVC FS']
['7', '3/4" PVC 90° Elbow', '406-007', 'SUP2', 'Y', 'PVC FS', 'PVC FS']
['7', '1" PVC 90° Elbow', '406-010', 'SUP2', 'Y', 'PVC FS', 'PVC FS']
['7', '1.25" PVC 90° Elbow', '406-012', 'SUP2', 'Y', 'PVC FS', 'PVC FS']
['7', '1.5" PVC 90° Elbow', '406-015', 'SUP2', 'Y', 'PVC FS', 'PVC FS']
['7', '2" PVC 90° Elbow', '406-020', 'SUP2', 'Y', 'PVC FS', 'PVC FS']
我明白了。 cursor.executemany 下的最后一行应为:
""", input_list)
我把右括号放错地方了