Guys I have a problem with mariadb, I try INSERT with this code:
import mariadb
conn_params= {
"user" : "example_user",
"password" : "GHbe_Su3B8",
"host" : "localhost",
"database" : "test"
}
connection= mariadb.connect(**conn_params)
cursor= connection.cursor()
cursor.execute("INSERT INTO countries(name, country_code, capital) VALUES (?,?,?)",
("Germany", "GER", "Berlin"))
Console don't report any error, finish normally, but don't commit the changes, how can I discovery any error without Raise?
So i tried with pandas, this time commit but the code stop with an error, I commented the Raise in mariadb/cursors.py like a print:
https://i.stack.imgur.com/2ayf8.png
So this worked after Raise comment, but I believe that can cause another error
df_insert.to_sql('tabela_handling', con=conn, if_exists='append', index=False)
Edit: This worked:
# connection parameters
conn_params= {
"user" : "user",
"password" : "pass",
"host" : "localhost",
"database" : "database"
}
# Establish a connection
connection= mariadb.connect(**conn_params)
cursor= connection.cursor()
sql_command= "INSERT INTO tabela_handling (data, hora, handling, usuario, midifydate) VALUES (?,?,?,?,?)"
data= ('22/09/2022', '17:40', '1', 'kelvin', '20/09/2022 22:45')
cursor.execute(sql_command, data)
connection.commit()
cursor.close()
connection.close()