Answer the question
In order to leave comments, you need to log in
Delete user from database if 403 bot was blocked by the user?
How to delete the person from the database if the user deleted the bot and the error
403 bot was blocked by the user during mailing?
def start(bot, update):
message = update.message
base_work.user_init(message.chat.id, message.chat.username, message.chat.first_name)
Answer the question
In order to leave comments, you need to log in
def post_sql_query(sql_query):
with sqlite3.connect(database) as connection:
cursor = connection.cursor()
try:
cursor.execute(sql_query)
except Error:
print(Error)
result = cursor.fetchall()
return result
def delete_user(user_id):
del_user_query = f'DELETE FROM users WHERE user_id = {user_id};'
post_sql_query(del_user_query)
try:
bot.send_message(user_id, text)
except telebot.apihelper.ApiException:
delete_user(user_id)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question