mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Use isolation_level=IMMEDIATE, refs #2358
This commit is contained in:
parent
a23c2aee00
commit
2edf45b1b6
1 changed files with 5 additions and 4 deletions
|
|
@ -85,12 +85,13 @@ class Database:
|
||||||
return "db"
|
return "db"
|
||||||
|
|
||||||
def connect(self, write=False):
|
def connect(self, write=False):
|
||||||
|
extra_kwargs = {}
|
||||||
|
if write:
|
||||||
|
extra_kwargs["isolation_level"] = "IMMEDIATE"
|
||||||
if self.memory_name:
|
if self.memory_name:
|
||||||
uri = "file:{}?mode=memory&cache=shared".format(self.memory_name)
|
uri = "file:{}?mode=memory&cache=shared".format(self.memory_name)
|
||||||
conn = sqlite3.connect(
|
conn = sqlite3.connect(
|
||||||
uri,
|
uri, uri=True, check_same_thread=False, **extra_kwargs
|
||||||
uri=True,
|
|
||||||
check_same_thread=False,
|
|
||||||
)
|
)
|
||||||
if not write:
|
if not write:
|
||||||
conn.execute("PRAGMA query_only=1")
|
conn.execute("PRAGMA query_only=1")
|
||||||
|
|
@ -111,7 +112,7 @@ class Database:
|
||||||
if self.mode is not None:
|
if self.mode is not None:
|
||||||
qs = f"?mode={self.mode}"
|
qs = f"?mode={self.mode}"
|
||||||
conn = sqlite3.connect(
|
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)
|
self._all_file_connections.append(conn)
|
||||||
return conn
|
return conn
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue