Answer the question
In order to leave comments, you need to log in
Strange problem when a command is executed at the same time and SQLite makes an error?
In general, I'm making a telegram bot. Faced the problem with SQQLite3. When the /gamecreate command is sent at the same time, the bot sends an error: cursor.execute('SELECT ban FROM users WHERE id = ?', (my_id, ))
ProgrammingError: Recursive use of cursors not allowed.
And the error does not always appear. What am I doing wrong?
@bot.message_handler(commands=["gamecreate"])
def createstol(message):
#Проверка на бан юзера
my_id = message.chat.id
cursor.execute('SELECT ban FROM users WHERE id = ?', (my_id, ))
ban_check = cursor.fetchone()
ban = str(ban_check[0])
if ban == 'False':
#Достаём подходящего игрока для совместной игры
cursor.execute('SELECT id_1 FROM stol_game WHERE id_2 = 0 AND id_1 != ? AND frend_id = 0', (my_id, ))
game_id_check = cursor.fetchone()
#Проверка на игрока, то есть бот ищёт с кем играть
if game_id_check == None:
bot.send_message(message.from_user.id, 'Увы, но сейчас не с кем играть')
else:
#Создаём рандомные значения от 1 до 6
brosok1 = random.randint(1, 6)
brosok2 = random.randint(1, 6)
global vsumme
vsumme = brosok1 + brosok2
@bot.message_handler(content_types=['text'])
def stavkainput(): #Идёт подключение
global stavka
stavka = int(message.text)
bot.send_message(message.fron_user.id, 'Гуд')
else:
bot.send_message(message.from_user.id, 'Ты забанен, обратись к администратору за выевлением причины выдачи бана и просьба, напиши свой id админу. Кстати твой id {}'.format(my_id))
bot.polling(none_stop=True, interval=0)
Answer the question
In order to leave comments, you need to log in
1. Come on, you learn to google, there are a lot of solutions to this problem, there is even a link to a similar question on this resource
2.
ban = str(ban_check[0])
if ban == 'False':
if game_id_check == None:
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question