diff --git a/yamdl_playground/core/apps.py b/yamdl_playground/core/apps.py index 83dcd7e..8200b13 100644 --- a/yamdl_playground/core/apps.py +++ b/yamdl_playground/core/apps.py @@ -15,7 +15,7 @@ class CoreConfig(AppConfig): from .models import Page if not self.loaded: - connection = connections["default"] + connection = connections["yamdl"] with warnings.catch_warnings(): # Django doesn't like running DB queries during app initialization @@ -34,8 +34,8 @@ class CoreConfig(AppConfig): if not created: return - with connections["default"].cursor() as cursor: + with connections["yamdl"].cursor() as cursor: cursor.execute("INSERT INTO search_index(body, rowid) VALUES (%s, %s)", [strip_tags(instance.content), instance.pk]) - with connections["default"].cursor() as cursor: + with connections["yamdl"].cursor() as cursor: cursor.execute("PRAGMA optimise;") diff --git a/yamdl_playground/core/views.py b/yamdl_playground/core/views.py index 257feed..e408b7d 100644 --- a/yamdl_playground/core/views.py +++ b/yamdl_playground/core/views.py @@ -7,7 +7,7 @@ from django.utils.safestring import mark_safe def search(request): - with connections["default"].cursor() as cursor: + with connections["yamdl"].cursor() as cursor: cursor.execute("SELECT rowid FROM search_index WHERE search_index = %s;", ["content"]) row = cursor.fetchone() pages = Page.objects.filter(id__in=row) diff --git a/yamdl_playground/settings.py b/yamdl_playground/settings.py index fb95167..4dc00e4 100644 --- a/yamdl_playground/settings.py +++ b/yamdl_playground/settings.py @@ -78,11 +78,8 @@ PRAGMA auto_vacuum=INCREMENTAL; DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': 'file:default-db?mode=memory&cache=shared', + 'NAME': BASE_DIR / "db.sqlite3", "CONN_MAX_AGE": 600, - "OPTIONS": { - "init_command": db_init_command - } }, 'yamdl': { 'ENGINE': 'django.db.backends.sqlite3', @@ -102,8 +99,8 @@ YAMDL_LOADER = "yamdl_playground.core.utils.CustomYamdlLoader" CACHES = { "default": { - "BACKEND": "django.core.cache.backends.filebased.FileBasedCache", - "LOCATION": BASE_DIR / "cache", + "BACKEND": "django.core.cache.backends.db.DatabaseCache", + "LOCATION": "database_cache", }, "mem": { "BACKEND": "django.core.cache.backends.locmem.LocMemCache",