Make WAL pragma optional for readonly deployments
This commit is contained in:
parent
e67d8ad0f5
commit
d580a4ac82
1 changed files with 5 additions and 1 deletions
|
|
@ -16,7 +16,11 @@ def get_conn() -> sqlite3.Connection:
|
||||||
def init_db() -> None:
|
def init_db() -> None:
|
||||||
DB_PATH.parent.mkdir(parents=True, exist_ok=True)
|
DB_PATH.parent.mkdir(parents=True, exist_ok=True)
|
||||||
with get_conn() as conn:
|
with get_conn() as conn:
|
||||||
|
try:
|
||||||
conn.execute("PRAGMA journal_mode = WAL")
|
conn.execute("PRAGMA journal_mode = WAL")
|
||||||
|
except sqlite3.OperationalError:
|
||||||
|
# Some deployments run with read-only db mounts; continue without WAL.
|
||||||
|
pass
|
||||||
conn.executescript(
|
conn.executescript(
|
||||||
"""
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS spot (
|
CREATE TABLE IF NOT EXISTS spot (
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue