So i'm trying to insert some data inside a for loop in sqlite database with python. I ve tried the following and none work:
conn.execute("INSERT INTO {table} ({colname}) VALUES ({val})"\
.format(table="Financial_Data",colname=sheet_results.cell(row=1,column=celula.col_idx).value,val=celula.value))
error:
sqlite3.OperationalError: near "name": syntax error
I've also tried this version:
conn.execute("INSERT INTO "Financial_Data" (?) VALUES (?)",(sheet_results.cell(row=1,column=celula.col_idx).value,celula.value)
The values are from openpyxl and they are tested. The error i recieve is syntax error.
this works(god knows why):
conn.execute('INSERT INTO Financial_Data ("Company name") VALUES (?)',(rand[1].value,))
What am i doing wrong? Much appreciated!