Answer the question
In order to leave comments, you need to log in
Python Telegram Bot. How to properly change data in Sqlite3 DB?
Hello! I ran into a problem when trying to create balance changes for a telegram bot I use TelegramBotAPI (aka telebot) and Sqlite3
user = message.from_user.id
sql = "UPDATE main SET balance = ? \
WHERE user_id = ?"
val = ("balance + 15", user)
c.execute(sql, val)
conn.commit()
When working in balance, it just writes the value "balance + 15", instead of adding 15 to the existing number
Tried to do it in an "unsafe" method :
c.execute("UPDATE main SET balance = balance + 15
WHERE user_id = user_id ")
conn.commit()
In this case, the balance is recorded correctly, but it only works if you manually specify the id of a specific user
Help. kind people
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