Answer the question
In order to leave comments, you need to log in
Why does not save the database?
The problem is that in one part of the code the output is 1 (example below), and in the other 0, that is, for some reason the database is not updated
con = sqlite3.connect("orders.db")
cur = con.cursor()
cur.execute(f"SELECT users FROM st;")
users = cur.fetchone()[0]
print(users)
us = users+1
print(us) #тут вывод 0
cur.execute(f"UPDATE st SET users = {us};")
conn.commit()
cur.execute(f"select users from st")
users1 = cur.fetchone()[0]
print(users1) #тут вывод 1
Answer the question
In order to leave comments, you need to log in
I can say one thing
just did not save
con = sqlite3.connect("orders.db")#тут con
cur = con.cursor()#тут тоже con
conn.commit()#а тут conn
I suppose that here
cur.execute(f"UPDATE st SET users = {us};")
you insert a number into users, and in the database there is a string type. The commit does not work and what was displayed is displayed.
Check the types in the database and those that you contribute.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question