core: use immutable mode in dataset helper
This commit is contained in:
parent
4fc33a9ed2
commit
49d25a75ae
1 changed files with 4 additions and 1 deletions
|
@ -4,6 +4,9 @@ from pathlib import Path
|
|||
def connect_readonly(db: Path):
|
||||
import dataset # type: ignore
|
||||
# see https://github.com/pudo/dataset/issues/136#issuecomment-128693122
|
||||
# todo not sure if mode=ro has any benefit, but it doesn't work on read-only filesystems
|
||||
# maybe it should autodetect readonly filesystems and apply this? not sure
|
||||
import sqlite3
|
||||
creator = lambda: sqlite3.connect(f'file:{db}?mode=ro', uri=True)
|
||||
# https://www.sqlite.org/draft/uri.html#uriimmutable
|
||||
creator = lambda: sqlite3.connect(f'file:{db}?immutable=1', uri=True)
|
||||
return dataset.connect('sqlite:///', engine_kwargs={'creator': creator})
|
||||
|
|
Loading…
Add table
Reference in a new issue