Max-Berater
Erfahrenes Mitglied
Code:
# Create Table
cursor.execute('''
CREATE TABLE products (
product_id int primary key,
product_name nvarchar(50),
price int
)
''')
# Insert DataFrame to Table
for row in df.itertuples():
cursor.execute('''
INSERT INTO products (product_id, product_name, price)
VALUES (?,?,?)
''',
row.product_id,
row.product_name,
row.price
)
conn.commit()
Traceback (most recent call last):
File "C:\Users\49152\PycharmProjects\shareanalysis\Pandas CSV_imp.py", line 30, in <module>
cursor.execute('''
TypeError: execute() takes from 2 to 4 positional arguments but 5 were given
Process finished with exit code 1
CSV
product_id product_name price
1 Laptop 1200
2 Printer 200
3 Tablet 350
4 Keyboard 80
5 Monitor 400
Zuletzt bearbeitet: