Answer the question
In order to leave comments, you need to log in
Not changing value in sq3lite python?
Hey Habr! I ran into a problem, I'm making a game bot for card games, I'm making an "admin panel" to change the balance of players. Through the regular season I brought out everything I needed, everything works well, but as you already understood, except for one flaw, the balance does not change. Hope you can help, thanks in advance! Libraries I use: re, random, sq3lite, vk_api, time. I attached only the part where it does not work, the rest functions normally
Changed: to change the balance I write "Change the balance of "id" "amount" (without quotes)"
elif "изменить баланс" in body.lower():
z=body.lower()
a = re.split(r'\W+', z)
b = a[2] #id
d = a[3] #balance
user_info = vk.method("users.get", {"user_ids": id, "fields": "first_name"})
user_id= user_info[0]["id"]
gg = тут мой айди
if user_id == gg:
vk.method("messages.send", {"peer_id": b, "message": "Ваш игровой баланс пополнен на " + str(d) + " йен.Приятной игры!", "random_id": random.randint(1, 2147483647)})
vk.method("messages.send", {"peer_id": id, "message": "Баланс пользователя успешно пополнен.", "random_id": random.randint(1, 2147483647)})
connection = sql.connect("user.sqlite", check_same_thread=False)
q = connection.cursor()
q.execute("SELECT * FROM user_info WHERE User_ID = %s" % (b))
q.execute("UPDATE user_info SET Balance = '%s' WHERE User_ID = '%s'" % (+ d, b)) or print("es")
print("balance changes")
connection.commit()
connection.close()
Answer the question
In order to leave comments, you need to log in
This part is questionable
q.execute("UPDATE user_info SET Balance = '%s' WHERE User_ID = '%s'" % (+ d, b)) or print("es")
q.execute("UPDATE user_info SET Balance = Balance + '%s' WHERE User_ID = '%s'" % (d, b)) or print("es")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question