I
I
Ilya Bugaets2020-07-02 21:02:44
Python
Ilya Bugaets, 2020-07-02 21:02:44

Why is db crashing?

The db crashes and the db-journal file is created after a few minutes of work. If you delete the log, then the bot works for a couple of minutes and crashes again and creates a log file. How to fix it?
Ps I am using sqlite3 and multiprocessing

Process Process-1:
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/process.py", line 313, in _bootstrap
    self.run()
  File "/usr/lib/python3.8/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/GCBOT/GCBOT/bot.py", line 82, in __call__
    db.commit()
sqlite3.OperationalError: database is locked

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
cython, 2020-07-02
@ilyabugaets

Working with sqlite3, through the same cursor, can only be done in the thread in which it was created. Either change the database, or use other technologies.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question