-
Hi, I have one more question how to use mmap enabled Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
This one gonna be more tricky. To not to it manually (call This is (out of context) more or less what class Connection(sqlite3.Connection):
def __init__(self, *args: Any, **kwargs: Any) -> None: # pragma: no cover
super().__init__(*args, **kwargs)
self.execute("PRAGMA foreign_keys=1;")
database = databases.Database(DATABASE_URL)
backend = database._backend
backend._options["factory"] = Connection
old_pool = backend._pool
backend._pool = old_pool.__class__(backend._database_url, **backend._options) So you need to provide your own Connection class and pass it to so your custom connection factory class can be something like: class Connection(sqlite3.Connection):
def __init__(self, *args: Any, **kwargs: Any) -> None: # pragma: no cover
super().__init__(*args, **kwargs)
self.execute("PRAGMA foreign_keys=1; PRAGMA mmap_size=268435456;") |
Beta Was this translation helpful? Give feedback.
This one gonna be more tricky.
Ormar already modifies sqlite settings but only to enforce foreign key usage.
To not to it manually (call
PRAGMA mmap_size=268435456;
before each query) you need to modify the factory forencode/databases
connection pool.This is (out of context) more or less what
ormar
does for you