Python/MySQL ProgrammingError: 1054 (42S22): Unknown column 'd' in 'field
list'
pmy program sends me the following error message after executing the
function to insert in the database:/p precodeTraceback: `Traceback (most
recent call last): File C:\Python33\Archive\MySQL-teste12.py, line 275, in
lt;modulegt; inserir(cursor, cx2) File
C:\Python33\Archive\MySQL-teste12.py, line 193, in inserir
cursor.execute(add_produto) File
C:\Python33\lib\site-packages\mysql\connector\cursor.py, line 415, in
execute self._handle_result(self._connection.cmd_query(stmt)) File
C:\Python33\lib\site-packages\mysql\connector\connection.py, line 593, in
cmd_query result = self._handle_result(self._send_cmd(ServerCmd.QUERY,
query)) File C:\Python33\lib\site-packages\mysql\connector\connection.py,
line 515, in _handle_result raise errors.get_exception(packet)
mysql.connector.errors.ProgrammingError: 1054 (42S22): Unknown column 'd'
in 'field list'` /code/pre pThe following table is trying to being
inserted:/p precodeproduto = CREATE TABLE produto ( prod_nu int(11) NOT
NULL AUTO_INCREMENT, nome varchar(30) NOT NULL, data_lcm date NOT NULL,
preco int(11) NOT NULL, PRIMARY KEY (prod_nu) ) ENGINE=InnoDB /code/pre
pHere is the procedure where the error occur. I believe it's not accepting
any format of date. I've tried many variations, and none of them worked:/p
precodedef inserir (cursor, db): menu3 = 0 while menu3 != 99: print( -----
Menu Banco MARK II, v.1.00, MySQL, VR ----- ----- Menu de Inserção ----
1.Inserir em produto. 2.Inserir em cliente. 3.Inserir em empregado.
4.Inserir em salario. 99.Sair. ) menu3 = input(Digite sua Opção) if menu3
== '1': va = input( Digite o Nome do Produto. ) vb = input( Digite a data
de Lançamento do Produto (Ano/mês/dia). ) now = time.strftime('vb') vc =
input( Digite o Preço do Produto (ex: 20, 20.33). ) add_produto = (INSERT
INTO produto(nome, data_lcm, preco) VALUES (%s, %s, %s)%(va,vb,vc)) #try:
cursor.execute(add_produto) db.commit() print( Inserção concluida com
sucesso. ) #except: # db.rollback() # print( # Erro. # ) if menu3 == '99':
break /code/pre pPlease assist./p
No comments:
Post a Comment