Answer the question
In order to leave comments, you need to log in
How to update data in sqlite?
I decided to make a casino for fun ( 'naturally not real' )
In general, there was such a problem, when he wins or loses, the balance should be updated,
but instead it gives the following error:
c.execute('UPDATE user_message SET (?)', (balance,))
sqlite3.OperationalError: near "?": syntax error
def update_balance(balance: int):
conn = get_connection()
c = conn.cursor()
c.execute('UPDATE user_message SET (?)', (balance,))
return c.fetchone()
@dp.callback_query_handler(text='red')
async def ssda(call: CallbackQuery):
await call.answer()
result = random.choice(random_rulet)
if result == 'Красное':
await call.message.answer(f'Выпало {result}, Вы победили!')
update_balance(balance=+ ctavka)
else:
update_balance(balance=+ ctavka)
await call.message.answer(f'Выпало {result}, Вы проиграли!')
Answer the question
In order to leave comments, you need to log in
I decided in the end myself:
It was right to write like this
def update_balance(balance: int):
conn = get_connection()
c = conn.cursor()
c.execute('UPDATE user_message SET balance=(?)', (balance,))
return c.fetchone()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question