W
W
windows8prew2018-02-17 15:54:12
Python
windows8prew, 2018-02-17 15:54:12

Python telebot and sqlite3 (Recursive use of cursors not allowed) help?

There is a telegram bot that sends messages, receiving information from the sqlite3 database:

@bot.message_handler(regexp=config[language]['cat_phones'])
def handle_text(message):
    cursor.execute('SELECT * FROM lots')
    for row in cursor:
        bot.send_message(message.from_user.id, '{0}\n{1}\n<b> {2:,} {3}</b>\n<b> {4:,} {3}</b>'.format(
        row[3], row[5], row[8], row[1], row[8]/100*20), parse_mode='HTML')

when 2 people press this button at the same time, the error `Recursive use of cursors not allowed` occurs
. And so, just before starting the bot, I found out that sqlite3 does not support multithreading.
Questions:
  1. How it is possible to solve this problem without passing to other type of a DB??
  2. What databases support multithreading?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dimonchik, 2018-02-17
@dimonchik2013

https://plyvel.readthedocs.io/en/latest/

O
Oleg, 2018-02-17
@OlegPyatakov

1. You can solve, for example, using Threading Lock in functions that work with the database.
2. All working on the network: MySQL, PostresQL, MongoDB and others.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question