Answer the question
In order to leave comments, you need to log in
How to set conditions?
How to set the right conditions?
'''
def give(my_id, user_id, nt_money):
connect = connection()
try:
with connect.cursor() as cursor:
result = cursor.execute(f'SELECT * FROM accounts WHERE id={user_id}')
row = cursor.fetchone()
if result == 1:
balanc = int(row['balance'])
balance = int(row['balance'])
'''
if int(nt_money) > balanc:
return "На вашем счету не достаточно средст!"
elif int(nt_money) <= 0:
return "Нельзя передавать отрицательные суммы!"
elif int(nt_money) <= balanc:
balanc -= int(nt_money)
balance += int(nt_money)
cursor.execute(f'UPDATE accounts SET balance={balanc} WHERE uid={my_id}')
cursor.execute(f'UPDATE accounts SET balance={balance} WHERE id={user_id}')
return f"Вы успешно перевели {nt_money} руб. на счёт пользователя (ID:{user_id})"
connect.commit()
'''
elif result == 0:
return 'Данный пользователь не зарегистрирован!'
finally:
connect.close()
'''
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