import csv
import psycopg2
conn = psycopg2.connect(database=" ", user=" ", password=" ", host=" ", port= )
cur = conn.cursor()
with open('21.csv', 'r') as f:
next(f)
cur.copy_from(f, 'temp_questions', sep=',')
conn.commit()
i have try to insert data into my db i got error:
cur.copy_from(f, 'temp_questions', sep=',')
psycopg2.errors.QueryCanceled: COPY from stdin failed: error in .read() call: exceptions.ValueError Mixing iteration and read methods would lose data
CONTEXT: COPY temp_questions, line 1
in my csv file -i have 18 column and table(database)- id with 18 column i don't know how to insert data