Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
( i am making a data base )

Hello, I have a big csv so I make this code:

import pandas as pd

concesionario = pd.read_csv("Coches/ventas.csv")

df = pd.DataFrame(concesionario)


and then I have the csv like df. Now I pick some columns and I make a new table:

cursor.execute('''
CREATE TABLE Pedido
(no_orden INT PRIMARY KEY NOT NULL, 
codigo_producto CHAR(20), 
cantidad_orden INT NOT NULL, 
precio_cada FLOAT (10), 
nombre_producto TEXT NOT NULL, 
linea_productos TEXT NOT NULL, 
descr TEXT NOT NULL, 
precio_compra FLOAT (10), 
fecha_orden DATE, 
no_cliente INT NOT NULL)

''')


next I want to put the information to csv to my new table

What I have tried:

I try:

for index,row in df.itertuples():
    cursor.execute('''
                INSERT INTO Pedido (no_orden, codigo_producto, cantidad_orden, precio_cada, nombre_producto, linea_productos, descr, precio_compra, fecha_orden, no_cliente)
                VALUES (?,?,?,?,?,?,?,?,?,?)
                '''
                )
conn.commit()


but give me this error:

ValueError: too many values to unpack (expected 2)


so I don't know how to solve it.
Posted
Updated 7-Nov-22 0:00am

1 solution

The pandas.DataFrame.itertuples — pandas 1.5.1 documentation[^] method does not return two items.

Also, the call to cursor.execute does not have any value data.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900