Answer the question
In order to leave comments, you need to log in
Why is the value not being output from sqlite3?
"Your balance" is not displayed (def enter()):
import sqlite3
global db
global sql
db = sqlite3.connect('pdftea.db')
sql = db.cursor()
sql.execute("""CREATE TABLE IF NOT EXISTS users (
login TEXT,
cash INT
)""")
db.commit()
def tea():
global ulogin
ulogin = "Sergey"
number = input("Сколько грамм: ")
if number == '40':
sql.execute('UPDATE users SET cash = cash + 40 WHERE login = ?',(ulogin, ))
print('Ваш баланс повышен на 40')
db.commit()
if number == '100':
print('Ваш баланс повышен на 100')
sql.execute('UPDATE users SET cash = cash + 100 WHERE login = ?',(ulogin, ))
db.commit()
def enter():
for i in sql.execute('SELECT cash FROM users'):
print("Ваш баланс" + i)
db.commit()
def main():
enter()
tea()
main()
Answer the question
In order to leave comments, you need to log in
Ruslan. absolutely right. Also, there is no login “Sergey” by default, so if it was not previously added to the database, .fetchall() will return an empty list and still nothing will be printed.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question