Answer the question
In order to leave comments, you need to log in
How to do an action on a variable in sql?
I'm making a program, I need it to take cash from the number I need (input). Tried a lot of things, nothing helped. Tell me how to do it ... Here is the program:
import sqlite3
global db
global sql
db = sqlite3.connect('serversi.db')
sql = db.cursor()
sql.execute("""CREATE TABLE IF NOT EXISTS users (
cash INT,
ware INT,
de INT
)""")
db.commit()
def casino():
number = input("Сколько грамм:")
if number == '40':
print('Ваш баланс повышен на 40')
sql.execute('UPDATE users SET cash = cash + 40')
db.commit()
elif number == '100':
print("Ваш баланс повышен на 100")
sql.execute('UPDATE users SET cash = cash + 100')
db.commit()
elif number == 'del':
den = input("Сколько снять:")
de = '1'
kk = '2'
sql.execute('INSERT INTO users VALUES (?,?,?)', (den, de, kk))
sql.execute('UPDATE users SET cash = cash - de')
print("Баланс снят на " + de)
db.commit()
def enter():
for i in sql.execute('SELECT cash FROM users'):
print(i)
for u in sql.execute('SELECT ware FROM users'):
print(u)
def main():
casino()
enter()
main()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question