Answer the question
In order to leave comments, you need to log in
Why is the table locked error?
I get this error when I simultaneously click on the inline button here is the code
if '21' not in mas_data_time:
await bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id)
ass = 'Картой'
conn_price_card = sqlite3.connect("Drive_in.db") # или :memory: чтобы сохранить в RAM
result_last_card = conn_price_card.execute(
f"""SELECT count FROM {user_id_start} WHERE id == 1""").fetchall()
for back_elem_card in result_last_card:
mazafaka_card = back_elem_card[0]
curr_Devit_pm.execute(f"UPDATE {user_id_start} SET oplata = '" + str(ass) + "' WHERE id =" + str(mazafaka_card))
Deveti_pm = curr_Devit_pm.execute(f"""SELECT * FROM {user_id_start}""").fetchall()
# Вывод результатов на экран
count_back_rr = 1
for Devet_pm in Deveti_pm:
await bot.send_message(call.from_user.id, str(count_back_rr) + ') ' + str(Devet_pm[7]))
abc = 1
table = 'Orders'
table_data = 'data_time'
a = '21'
curr_Devit_pm.execute(
f"""INSERT INTO {table} (name, user_name, shop, phone, price, bazar_tovar, oplata, clock) VALUES(?, ?, ?, ?, ?, ?, ?, ?)""",
(Devet_pm[3], Devet_pm[4], Devet_pm[5], Devet_pm[6], Devet_pm[7], Devet_pm[2], Devet_pm[11],
a))
curr_Devit_pm.execute(f"""DELETE FROM {user_id_start} WHERE id > 1""")
curr_Devit_pm.execute(f"UPDATE {user_id_start} SET count = '" + str(1) + "' WHERE id =" + str(1))
curr_Devit_pm.execute(f"UPDATE {user_id_start} SET location = '" + str(0) + "' WHERE id =" + str(1))
curr_Devit_pm.execute(f"""INSERT INTO {table_data} (clock) VALUES(?)""",
(a,))
con_Devit_pm.commit()
else:
await bot.send_message(call.message.chat.id, 'Это время уже забронированно выберите другое :(')
Answer the question
In order to leave comments, you need to log in
sqlite allows you to open only one connection to the database at a time, respectively, the first time you clicked - opened the database -> the database is blocked while it is open. Pressed a second time, sqlite tries to open it, but it is blocked because the first action did not complete.
Use more advanced tables for concurrent access
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question