Do not insert records in mysql database

0

I have a problem with inserting records in MySQL database with python, using the code shown below I try to insert the values that I show and they do not appear in the DB. I made a query and if it is done correctly, I checked the parameters and also they do not have any errors, I have an arduino that continuously inserts in that database so I doubt that the problem is of the DB. Everything I do in Raspbian using a Raspberry Pi 3

The code below

import mysql.connector

dato = {
 'user':'user',
 'password':'password',
 'database':'database',
 'host':'www.midireccion.com'
 } 

con = mysql.connector.connect(** dato)
cursor = con.cursor()
valores = "INSERT INTO DispData (Dis,H,S) VALUES 
('85439313130351D032D0','62','0')"

try:
    con.cursor(valores)
    con.commit()
    print("Valores ingresados correctamente")
except:
    print("Error")

con.close()
    
asked by Juan Trinidad Mayo 20.02.2018 в 22:35
source

1 answer

0

Could you except for this?

except mysql.connector.Error as err:
   print("Hubo un error: {}".format(err))

In this way we could know more about it

// sacado de las documentaciones de MySQL-Python:
-> https://dev.mysql.com/doc/connector-python/en/connector-python-api-errors-error.html
    
answered by 20.02.2018 в 23:07