From 43c5c45da43208d45a5ad82a6e06b592ebb70439 Mon Sep 17 00:00:00 2001 From: Andy Shapiro Date: Fri, 9 Aug 2024 10:39:58 -0400 Subject: [PATCH] update to django 5.1 --- bmds_ui/desktop/sqlite3/__init__.py | 0 bmds_ui/desktop/sqlite3/base.py | 31 ----------------------------- bmds_ui/main/settings/desktop.py | 6 +++++- pyproject.toml | 10 +++++----- 4 files changed, 10 insertions(+), 37 deletions(-) delete mode 100644 bmds_ui/desktop/sqlite3/__init__.py delete mode 100644 bmds_ui/desktop/sqlite3/base.py diff --git a/bmds_ui/desktop/sqlite3/__init__.py b/bmds_ui/desktop/sqlite3/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/bmds_ui/desktop/sqlite3/base.py b/bmds_ui/desktop/sqlite3/base.py deleted file mode 100644 index 6de3d7a9..00000000 --- a/bmds_ui/desktop/sqlite3/base.py +++ /dev/null @@ -1,31 +0,0 @@ -from sqlite3 import dbapi2 as Database - -from django.db.backends.sqlite3 import base -from django.db.backends.sqlite3._functions import register as register_functions -from django.utils.asyncio import async_unsafe - - -class DatabaseWrapper(base.DatabaseWrapper): - # TODO - remove w/ django 5.1 release - # adapted from https://blog.pecar.me/sqlite-django-config - # https://gcollazo.com/optimal-sqlite-settings-for-django/ - def _start_transaction_under_autocommit(self): - # Acquire a write lock immediately for transactions - self.cursor().execute("BEGIN IMMEDIATE") - - @async_unsafe - def get_new_connection(self, conn_params): - conn = Database.connect(**conn_params) - register_functions(conn) - - conn.execute("PRAGMA foreign_keys=ON") - conn.execute("PRAGMA legacy_alter_table = OFF") - conn.execute("PRAGMA journal_mode = WAL") - conn.execute("PRAGMA synchronous = NORMAL") - conn.execute("PRAGMA busy_timeout = 5000") - conn.execute("PRAGMA temp_store = MEMORY") - conn.execute("PRAGMA mmap_size = 134217728") - conn.execute("PRAGMA journal_size_limit = 67108864") - conn.execute("PRAGMA cache_size = 2000") - - return conn diff --git a/bmds_ui/main/settings/desktop.py b/bmds_ui/main/settings/desktop.py index e2d9f32e..c6c52b68 100644 --- a/bmds_ui/main/settings/desktop.py +++ b/bmds_ui/main/settings/desktop.py @@ -32,8 +32,12 @@ DATABASES = { "default": { - "ENGINE": "bmds_ui.desktop.sqlite3", + "ENGINE": "django.db.backends.sqlite3", "NAME": os.getenv("BMDS_DB", APP_HOME / "bmds-desktop.db"), + "OPTIONS": { + "transaction_mode": "IMMEDIATE", + "init_command": "PRAGMA foreign_keys=ON; PRAGMA legacy_alter_table = OFF; PRAGMA journal_mode = WAL; PRAGMA synchronous = NORMAL; PRAGMA busy_timeout = 5000; PRAGMA temp_store = MEMORY; PRAGMA mmap_size = 134217728; PRAGMA journal_size_limit = 67108864; PRAGMA cache_size = 2000;", + }, } } diff --git a/pyproject.toml b/pyproject.toml index a0536740..a6343c16 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,11 +22,11 @@ dependencies = [ "pybmds==24.1a3", # website - "Django~=5.0.7", - "django-anymail~=10.3", + "Django~=5.1.0", + "django-anymail~=11.1", "django-redis~=5.4.0", "django-webpack-loader~=3.1.0", - "djangorestframework~=3.15.1", + "djangorestframework~=3.15.2", "uritemplate~=4.1.1", "django-reversion~=5.0.12", "PyYAML~=6.0.1", @@ -50,9 +50,9 @@ dev = [ "flit~=3.9.0", # debug - "django-debug-toolbar~=4.3.0", + "django-debug-toolbar~=4.4.6", "django_extensions==3.2.3", - "django-browser-reload==1.12.1", + "django-browser-reload==1.13.0", # tests "pytest~=8.2.1",