From 0787d057da0dab422f8900869448c2f9e6692165 Mon Sep 17 00:00:00 2001 From: Ethan Paul <24588726+enpaul@users.noreply.github.com> Date: Wed, 24 Nov 2021 22:41:58 -0500 Subject: [PATCH] Add default sqlite pragma dictionary --- peewee_plus.py | 16 +++++++++++++--- tests/fixtures.py | 10 +++------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/peewee_plus.py b/peewee_plus.py index 735e823..d8b4c4b 100644 --- a/peewee_plus.py +++ b/peewee_plus.py @@ -20,15 +20,25 @@ __authors__ = ["Ethan Paul <24588726+enpaul@users.noreply.github.com>"] __all__ = [ + "calc_batch_size", + "EnumField", + "JSONField", "PathField", "PrecisionFloatField", - "JSONField", - "EnumField", + "SQLITE_DEFAULT_PRAGMAS", "SQLITE_DEFAULT_VARIABLE_LIMIT", - "calc_batch_size", ] +SQLITE_DEFAULT_PRAGMAS: Dict[str, Any] = { + "journal_mode": "wal", + "cache_size": -1 * 64000, + "foreign_keys": 1, + "ignore_check_constraints": 0, + "synchronous": 0, +} + + SQLITE_DEFAULT_VARIABLE_LIMIT: int = 999 diff --git a/tests/fixtures.py b/tests/fixtures.py index 562b753..c0f624a 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -3,6 +3,8 @@ import uuid import peewee import pytest +import peewee_plus + @pytest.fixture(scope="function") def fakedb(tmp_path): @@ -10,13 +12,7 @@ def fakedb(tmp_path): sqlite = peewee.SqliteDatabase( str(tmp_path / f"{uuid.uuid4()}.db"), - pragmas={ - "journal_mode": "wal", - "cache_size": -1 * 64000, - "foreign_keys": 1, - "ignore_check_constraints": 0, - "synchronous": 0, - }, + pragmas=peewee_plus.SQLITE_DEFAULT_PRAGMAS, ) yield sqlite