mentheosis / anki-scanner-chinese-redux

adding text scanning features for chinese redux in anki
GNU General Public License v3.0
5 stars 5 forks source link

All scan attempts result in: 'sqlite3.OperationalError: database is locked' #12

Open mcmathmo opened 3 years ago

mcmathmo commented 3 years ago

Describe the bug I get a 'sqlite3.OperationalError: database is locked' error whenever I scan pasted text or from a file.

To Reproduce Steps to reproduce the behavior:

  1. Go to 'TextScan'
  2. Click on 'Scan pasted text'
  3. Paste any chinese text into the 'Input text:' box
  4. Press 'Run the scan!'
  5. Wait for ~10 seconds
  6. See error:
Debug info:
Anki 2.1.38 (355e4cd5) Python 3.8.6 Qt 5.14.2 PyQt 5.14.2
Platform: Windows 10
Flags: frz=True ao=True sv=1
Add-ons, last update check: 2021-01-09 22:05:03

Caught exception:
Traceback (most recent call last):
  File "C:\Users\mcmathmo\AppData\Roaming\Anki2\addons21\2121493325\mr_async_worker_thread.py", line 60, in run
    self.new_char_words, self.new_words, self.new_chars, self.printSummary = sc.scan_and_print(self.file_to_scan, self.file_or_dir, self.input_encoding, self.scan_mode)
  File "C:\Users\mcmathmo\AppData\Roaming\Anki2\addons21\2121493325\mr_text_scanner.py", line 296, in scan_and_print
    scanned_words, anki_words, left_diff, intersect, scanned_chars, anki_chars, char_diff, char_intersect = self.scan_and_compare(
  File "C:\Users\mcmathmo\AppData\Roaming\Anki2\addons21\2121493325\mr_text_scanner.py", line 279, in scan_and_compare
    self.load_words_from_anki_notes()
  File "C:\Users\mcmathmo\AppData\Roaming\Anki2\addons21\2121493325\mr_text_scanner.py", line 194, in load_words_from_anki_notes
    c.execute(query)
sqlite3.OperationalError: database is locked

I also receive an identical error when trying to scan from a file.

Screenshots image

mentheosis commented 3 years ago

Hello @mcmathmo sorry I didn't see this sooner. From what you've posted, it seems like the scanner is competing for access to the database. Is your anki doing some other work at the same time, or do you have another plugin running perhaps? Let me know if you are still interested and I can help research

Here is a stackoverflow on that error: https://stackoverflow.com/questions/3172929/operationalerror-database-is-locked/39449185

camerooncameroon commented 2 years ago

Hi, I also was getting the 'database locked' error when I set the path to the opened collection.anki2 file. When I changed the path to the newly created empty .anki2 file (unzipped from a newly made .apkg), this error disappeared, but I got another instead: #16

kris-w-stkd commented 2 years ago

Hi, I also was getting the 'database locked' error when I set the path to the opened collection.anki2 file. When I changed the path to the newly created empty .anki2 file (unzipped from a newly made .apkg), this error disappeared, but I got another instead: #16

Hi @camerooncameroon can you tell me what operating system you have, what anki version, and if you have any other anki plugins running?

Creating a new empty db like you did will not work because then it wont be able to see what cards you have in your collection or create new cards. It's meant to interact with your main anki db. We should be able to figure out why the db is being accessed in parallel though and get it working

camerooncameroon commented 2 years ago

Hi @mentheosis, I gathered all this information and placed it here #16