# SQLITE\_BUSY on database access

**URL:** <https://forums.ankiweb.net/t/sqlite-busy-on-database-access/4295>\
**Category:** Development\
**Created:** [October 13, 2020, 6:07pm UTC](https://forums.ankiweb.net/t/sqlite-busy-on-database-access/4295 "2020-10-13T18:07:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martijn](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/martijn/32/2140_2.png) [@Martijn](https://forums.ankiweb.net/u/Martijn)\
**Post date:** [October 13, 2020, 6:07pm UTC](https://forums.ankiweb.net/t/sqlite-busy-on-database-access/4295/1 "2020-10-13T18:07:36Z")

</div>

(Skip to last sentence for question without context)

I recently updated to 2.1.35 (84dcaa86), from some earlier version of I believe 2.1. I am using external code to read the .anki2 file (only read) for detailed information on the cards (I haven’t found a way to distinguish between unseen and learning on the first day using only AnkiConnect) and external processing (for tracking for lessons I have).

While using this new version, if Anki is being used, it acquires a SQLite lock, so I will get an error in the external application:  
“[SQLITE\_BUSY] The database file is locked (database is locked)”

I am also using AnkiConnect, so I have to keep Anki running while the code is running.

All in all, what I want to ask is:  
Could the code be modified to execute a SQL query “pragma journal\_mode=wal” so that external programs can read the database (not write) it safely while Anki is running?

---

<div class="post-metadata">

**Author:** ![dae](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/dae/32/65_2.png) [@dae](https://forums.ankiweb.net/u/dae)\
**Post date:** [October 13, 2020, 10:46pm UTC](https://forums.ankiweb.net/t/sqlite-busy-on-database-access/4295/2 "2020-10-13T22:46:37Z")

</div>

Anki does not expect the database to be accessed externally while it is running. You’ll either need to close Anki first, or create a copy of the DB to work with.

---

<div class="post-metadata">

**Author:** ![Martijn](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/martijn/32/2140_2.png) [@Martijn](https://forums.ankiweb.net/u/Martijn)\
**Post date:** [October 14, 2020, 10:11am UTC](https://forums.ankiweb.net/t/sqlite-busy-on-database-access/4295/3 "2020-10-14T10:11:41Z")

</div>

I just created a copy of the file to work with. Thank you, problem solved! 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/1X/8f1279ababc5879d54e4838989f606cfe55af8c7.jpeg) [@system](https://forums.ankiweb.net/u/system)\
**Post date:** [May 1, 2023, 3:20am UTC](https://forums.ankiweb.net/t/sqlite-busy-on-database-access/4295/4 "2023-05-01T03:20:32Z")

</div>


