0

I don't seem to be making new users

def new_user(): Username = input("Enter Username: ") Password = input("Enter Password: ") import mysql.connector, re mydb = mysql.connector.connect(host="localhost", user="jeremy", password="jcvcruz123", database = "logdata") my_cursor = mydb.cursor() my_cursor.execute('SELECT id FROM Info;') id = str(my_cursor.fetchall()) idnum = int(re.findall(r'\d+', id)[-1]) + 1 print(idnum) my_cursor.execute('INSERT INTO Info VALUES(', idnum, ', "' + Username + '", "' + Password + '")') my_cursor.execute('SELECT * FROM Info;') myresult = my_cursor.fetchall() print(myresult) new_user()

7th Jun 2020, 12:04 AM
Jeremy Cruz
Jeremy Cruz - avatar
1 Odpowiedź
+ 4
You have to commit() the changes to your database. mydb.commit() https://www.w3schools.com/JUMP_LINK__&&__python__&&__JUMP_LINK/python_mysql_insert.asp
7th Jun 2020, 12:30 AM
ChaoticDawg
ChaoticDawg - avatar