Answer the question
In order to leave comments, you need to log in
How to compare user id with id in sqlite database?
This is how I read, write down and delete IDs from the database.
def select_with_fetchall():
cmd = "SELECT user_id FROM banlist"
c.execute(cmd)
result = c.fetchall()
print(result)
def insert():
cmd = "INSERT INTO banlist(user_id) VALUES (%d)" % (event.obj.reply_message['from_id'])
c.execute(cmd)
conn.commit()
print("Пользователь добавлен в черный список")
def delete():
cmd = "DELETE FROM banlist WHERE user_id=%d" % event.obj.reply_message['from_id']
c.execute(cmd)
conn.commit()
print("Пользователь удален из черного списка")
if event.object.text == "Бан" or event.object.text == "бан":
if event.obj.from_id in get_admins(event.obj.peer_id):
insert()
kick_user_fwd()
if event.object.text == "Анбан" or event.object.text == "анбан":
if event.obj.from_id in get_admins(event.obj.peer_id):
delete()
send_msg(event.obj.peer_id, "Пользователь разбанен")
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