# See extensive tutorial here https://docs.python.org/3/library/sqlite3.html import sqlite3 con = sqlite3.connect("bank.db", autocommit=True) cur = con.cursor() print() print("Running a SELECT query:") res = cur.execute("SELECT * FROM acc") answ = res.fetchall() print("The answer is: ", answ) print() # comment here print("Running an UPDATE query:") # everyone gets an interest of 4% for row in answ: usr = row[0] bal = row[1] b = int(bal) i = b*0.04 print("User "+usr+" has an interest of "+str(i)) print("Upating the balance") cur.execute("UPDATE acc SET balance=? WHERE usr=?", [b+i, usr]) print() print("Running the SELECT query again:") res = cur.execute("SELECT * FROM acc") answ = res.fetchall() print("The answer is: ", answ)