Someone can help me!
I am reading from a csv file and then I do an INSERT on the MySQL database, but I get the following error
KeyError: 'id'
I have checked the CSV file several times, the file has all the columns and exactly the same name.
importcsvimportpymysql#importaoarquivodeacessoaobancofromconfigimportconfig#fazaconexãocomobancodedadoscnx=pymysql.connect(**config,charset='utf8')cursor=cnx.cursor()#leroarquivocsvinput_file=csv.DictReader(open("teste.csv", encoding='utf-8'))
# importa o arquivo csv no banco de dados
for row in input_file:
cursor.execute("INSERT INTO teste.tabela (id,nome) \
VALUES (%s,%s)",(row['id'],row['nome']))
print("Importando Linhas")
cnx.commit()