Skip to content

Commit

Permalink
Use isolation_level=IMMEDIATE, refs #2358
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Jul 16, 2024
1 parent a23c2ae commit 2edf45b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions datasette/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,13 @@ def suggest_name(self):
return "db"

def connect(self, write=False):
extra_kwargs = {}
if write:
extra_kwargs["isolation_level"] = "IMMEDIATE"
if self.memory_name:
uri = "file:{}?mode=memory&cache=shared".format(self.memory_name)
conn = sqlite3.connect(
uri,
uri=True,
check_same_thread=False,
uri, uri=True, check_same_thread=False, **extra_kwargs
)
if not write:
conn.execute("PRAGMA query_only=1")
Expand All @@ -111,7 +112,7 @@ def connect(self, write=False):
if self.mode is not None:
qs = f"?mode={self.mode}"
conn = sqlite3.connect(
f"file:{self.path}{qs}", uri=True, check_same_thread=False
f"file:{self.path}{qs}", uri=True, check_same_thread=False, **extra_kwargs
)
self._all_file_connections.append(conn)
return conn
Expand Down

0 comments on commit 2edf45b

Please sign in to comment.