I'm trying to load csv data into a database that I've already built, and am getting the above noted error. The CSV file only has 29 rows, everything is spelled correctly, I just don't know if I'm missing out on some small piece of syntax? Can anyone recommend how to resolve this or where I may be going wrong?
My function is detailed below:
def load_csv_to_db():
db_file_name = 'records.db'
csv_file_name = '13100262.csv'
SQL = """
insert into records_table (ref_date,geo,dguid,sex,age_group,student_response,uom,uom_id,scalar_factor,scalar_id,
vector,coordinate,value,status,symbol,terminated,decimals) values (:ref_date,:geo,:dguid,:sex,:age_group,
:student_response,:uom,:uom_id,:scalar_factor,:scalar_id,:vector,:coordinate,:value,:status,:symbol,:terminated,
:decimals)"""
with open(csv_file_name, 'rt') as csv_file:
csv_reader = csv.DictReader(csv_file)
with sq.connect(db_file_name) as conn:
cursor = conn.cursor()
cursor.executemany(SQL, csv_reader)