0

I'm trying to make a simple thing, inserting all those values into a database, but when run it, it won't insert anything, no error will be shown though. (I'm no more than a beginner, sorry if the solution is obvious)

This is the code, function extracted from a discord bot I'm experimenting with in python.

import mysql.connector

id_discord = 397439760676945930
nick_discord = "zascan"
region = "EUW"
nick_lol = "ZascanGamer"
rank = "MASTER"
lps = "0LP"
region_rank = 4010


mydb = mysql.connector.connect(
        host = "localhost",
        user = "root",
        password = "",
        database = "servidor_discord")
cursor = mydb.cursor(dictionary=True)

sql = "INSERT INTO usuarios (ID_DISCORD, NICK_DISCORD, REGION, NICK_LOL, RANGO, LPS, RANGO_REGION) VALUES (%s,%s,%s,%s,%s,%s,%s)"
cursor.execute(sql, (id_discord, nick_discord, region, nick_lol, rank, lps, region_rank))I
Zascan
  • 1
  • Are you forced to use phpadmin due to a PLESK or other scenario? If not, today is your lucky day, try MySQL Workbench its everything phpadmin is missing or lacks. https://dev.mysql.com/downloads/workbench/ – easleyfixed Jun 13 '23 at 17:04
  • Side note -- read this link and see if it helps -- https://stackoverflow.com/questions/372885/how-do-i-connect-to-a-mysql-database-in-python?rq=2 – easleyfixed Jun 13 '23 at 17:07
  • Ok, I figured out and it's a really simple thing, I have to write one last linecode: mydb.commit() (Three hours researching just to being that haha. Thanks for the two that commented. Sorry I'm an idiot) – Zascan Jun 13 '23 at 17:18
  • Ah yes, I'm not even sure how its possible that you don't have a START TRANSACTION but it requires the COMMIT but It seems to be a phpmyadmin thing. But the point of those normally is you start transaction then do all the statements you want, then close out with Commit so it actually does all of them in sequence with the data at the time of selection. But with MySQL Workbench I only have to use commit if there is a start transaction, not sure why phpadmin does it that way. – easleyfixed Jun 13 '23 at 17:24

0 Answers0