1
I am trying to pass my "table" variable to the mysql command, but it is returning an error (of sql) during execution. What am I missing?
Here I created the table variable
table = input('Table name: ')
while(tabela not in tabelasCadastradas):
tabela = input('Tabela não cadastrada. Digite novamente:'.upper())
print(('Menu -> 1- Adicionar questão').upper())
opcaoMenu = input('')
while(opcaoMenu != '1'):
opcaoMenu = ('Opção inválida. Digite novamente: '.upper())
tema = input('Tema: '.upper())
enunciado = input('Enunciado: '.upper())
Here is giving error
crawler.execute('INSERT INTO "%s" (id, tema, enunciado) VALUES (id, "%s", "%s")'%(tabela, tema, enunciado))
Conn.close()
What is the error that appears?
– Renato Junior
Says I have a syntax error in mysql command.
– puma_hobby
pymysql.err.Programmingerror: (1064, 'You have an error in your SQL syntax;
– puma_hobby
When I do Crawler.execute('INSERT INTO" (id, theme, enunciation) VALUES (id, "%s", "%s")'%(theme, enunciation)), works perfectly. So I know it’s really something wrong when passing the table variable as parameter.
– puma_hobby