| 281 | ``OperationalError: database is locked`` errors |
| 282 | ----------------------------------------------- |
| 283 | |
| 284 | ``OperationalError: database is locked`` errors indicate that your application |
| 285 | is experiencing more concurrency than ``pysqlite`` can handle in default |
| 286 | configuration. Note that a SQLite database is essentially accessed in serial |
| 287 | manner in threaded environment, so the error means that one thread has an |
| 288 | exclusive lock on the SQLite database connection and another thread was trying |
| 289 | to use the same connection, but timed out waiting on the lock. ``pysqlite`` has |
| 290 | a default timeout value that determines how long the second thread is allowed to |
| 291 | wait on the lock before it times out and raises the ``OperationalError: database |
| 292 | is locked`` error. |
| 293 | |
| 294 | To avoid the error, you can either |
| 295 | |
| 296 | * use another database backend or |
| 297 | |
| 298 | * reduce concurrency by ensuring that your database transactions are |
| 299 | short-lived or |
| 300 | |
| 301 | * increase the default timeout value by setting the ``timeout`` option:: |
| 302 | |
| 303 | DATABASE_OPTIONS = { |
| 304 | # ... |
| 305 | "timeout": 20, |
| 306 | # ... |
| 307 | } |
| 308 | |