// sqlite · timeouts

busy_timeout

Milliseconds to keep retrying when the database is locked by another connection, instead of failing with SQLITE_BUSY.

デフォルト
0
Range
0 or more ms
Restart needed
いいえ
Default checked on
SQLite 3.5x

何ができるか

Equivalent to calling sqlite3_busy_timeout(). Without it, a second writer fails immediately with 'database is locked'.

デフォルト値

0. 0 in the C library (a stock SQLite 3.5x build). Wrappers differ: Python's sqlite3 module opens connections with a 5000ms timeout.

Check the current value

PRAGMA busy_timeout;

SELECT * FROM pragma_busy_timeout;   -- table-valued form, usable in queries

Change it

PRAGMA busy_timeout = 5000;   -- this connection only

No restart. It applies at once to the connection that runs it and is lost when that connection closes, so set it every time a connection opens.

When to change it

In every application with more than one connection or process writing to the same file.

What can go wrong

Too long makes requests hang behind a long write transaction; it also cannot resolve the deadlock of two readers upgrading to writers (use BEGIN IMMEDIATE for write transactions).

The closest setting on other engines

エンジン設定デフォルトRestart
SQLite busy_timeout this page 0 いいえ
PostgreSQL lock_timeout 0 (disabled) いいえ
MySQL innodb_lock_wait_timeout 50 いいえ
SQL Server LOCK_TIMEOUT -1 (wait forever) いいえ

Questions about busy_timeout

What is the default value of busy_timeout in SQLite?

0. 0 in the C library (a stock SQLite 3.5x build). Wrappers differ: Python's sqlite3 module opens connections with a 5000ms timeout.

Does changing busy_timeout require a restart?

No. No restart. It applies at once to the connection that runs it and is lost when that connection closes, so set it every time a connection opens.

When should I change busy_timeout?

In every application with more than one connection or process writing to the same file.

Back to all SQLite settings, or check the SQLite manual for every option.

// one client for every engine

Check busy_timeout on your own server

SQLly runs the query above against SQLite and the other engines in this reference, from one desktop app on macOS, Windows and Linux.