You might want to start the w3schools tutorial from the beginning. https://www.w3schools.com/python/python_mysql_getstarted.asp
I forgot to do% s when inserting a variable in a loop https://www.w3schools.com/python/python_mysql_insert.asp ''' import mysql.connector
mydb = mysql.connector.connect( host="localhost", user="yourusername", passwd="yourpassword", database="mydatabase" )
mycursor = mydb.cursor()
sql = "INSERT INTO customers (name, address) VALUES (%s, %s)" val = ("John", "Highway 21") mycursor.execute(sql, val)
mydb.commit()
print(mycursor.rowcount, "record inserted.") '''
About UNIQUE Constraint https://www.w3schools.com/sqL/sql_unique.asp
to_sql in pandas https://www.haya-programming.com/entry/2019/05/03/043334
Recommended Posts