mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-10-02 16:50:20 +03:00
Enable SQLite WAL mode to fix 'database is locked' errors under concurrent API requests
This commit is contained in:
parent
650be3565f
commit
49d2c271ca
@ -149,9 +149,12 @@ async def disconnect_from_db(app: FastAPI) -> None:
|
|||||||
@event.listens_for(Engine, "connect")
|
@event.listens_for(Engine, "connect")
|
||||||
def set_sqlite_pragma(dbapi_connection, connection_record):
|
def set_sqlite_pragma(dbapi_connection, connection_record):
|
||||||
|
|
||||||
|
# Enable WAL mode for SQLite to allow concurrent reads and writes.
|
||||||
|
# Without WAL, concurrent API requests can cause "database is locked" errors.
|
||||||
|
cursor = dbapi_connection.cursor()
|
||||||
|
cursor.execute("PRAGMA journal_mode=WAL")
|
||||||
# Enable SQL foreign key support for SQLite
|
# Enable SQL foreign key support for SQLite
|
||||||
# https://docs.sqlalchemy.org/en/14/dialects/sqlite.html#foreign-key-support
|
# https://docs.sqlalchemy.org/en/14/dialects/sqlite.html#foreign-key-support
|
||||||
cursor = dbapi_connection.cursor()
|
|
||||||
cursor.execute("PRAGMA foreign_keys=ON")
|
cursor.execute("PRAGMA foreign_keys=ON")
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user