I have the following function which inserts two values into my database, however, no matter how many times I try, the data is just not inserted. newname and newgrade are also successfully fetched in this function, just not passed to the database.
def addtolist():
with sqlite3.connect("TestScore.db") as db:
cursor = db.cursor()
newname = sname.get()
newgrade = sgrade.get()
cursor.execute("""INSERT INTO Scores(name,score) VALUES (?,?)""", (newname, newgrade))
db.commit
sname.delete(0, END)
sgrade.delete(0, END)
sname.focus()
And I created the database like following
cursor.execute(""" CREATE TABLE IF NOT EXISTS Scores (id integer PRIMARY KEY, name text, score integer); """)
.commit.close()function.