Is this somewhat efficient?
import mysql.connector, re mydb = mysql.connector.connect(host="localhost", user="jeremy", password="jcvcruz123", database = "logdata") def new_user(): Username = input("Enter Username: ") Password = input("Enter Password: ") my_cursor.execute('select id from Input;') id = str(my_cursor.fetchall()) if id == "[]": idnum = 0 else: idnum = int(re.findall(r'\d+', id)[-1]) + 1 insert = 'insert into Input values( ' + str(idnum) + ', "' + Username + '", "' + Password + '");' my_cursor.execute(insert) mydb.commit() print("Addition was successful") my_cursor = mydb.cursor() keyword = input('"Add", "Clear", or "Display": ') if keyword == "Clear": my_cursor.execute("delete from Input;") mydb.commit() print("Successfully cleared!") elif keyword == "Display": my_cursor.execute("select * from Input;") records = my_cursor.fetchall() for i in records: print(i) else: new_user()