From 4b96c8bd1d6c77f59a99317aac2a30948c1f9f6f Mon Sep 17 00:00:00 2001 From: graynk Date: Sun, 20 Feb 2022 21:56:56 +0500 Subject: [PATCH] of course we need to subtract balance from specific user --- bot.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bot.py b/bot.py index 220db8a..66136cf 100644 --- a/bot.py +++ b/bot.py @@ -35,7 +35,7 @@ dispatcher = updater.dispatcher speech_client = SpeechClient() storage_client = storage.Client() -conn = psycopg2.connect('host=db dbname=voicos user=bot password=voicosdb') +conn = psycopg2.connect('host=localhost dbname=voicos user=postgres password=bruhpostgres') def start(update: Update, context: CallbackContext) -> None: @@ -141,8 +141,8 @@ def transcribe(file_name: str, message: Message, lang_code: str = 'ru-RU', alter with conn.cursor() as cur: cur.execute("insert into customer(user_id) values (%s) on conflict (user_id) do nothing;", (message.chat_id,)) - cur.execute("update customer set balance = balance - (%s);", - (actual_duration,)) + cur.execute("update customer set balance = balance - (%s) where user_id = (%s);", + (actual_duration, message.chat_id)) cur.execute("insert into stat(user_id, message_timestamp, duration) values (%s, current_timestamp, %s);", (message.chat_id, actual_duration)) conn.commit()