27 lines
1 KiB
Python
27 lines
1 KiB
Python
# This file is part of photo21
|
|
# Copyright (C) 2022 Amicale des élèves de l'ENS Paris-Saclay
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
from django.apps import AppConfig
|
|
from django.db.backends.signals import connection_created
|
|
|
|
|
|
class PhotologueConfig(AppConfig):
|
|
default_auto_field = "django.db.models.AutoField"
|
|
name = "photologue"
|
|
|
|
def ready(self):
|
|
from django.db import connection
|
|
|
|
def enable_sqlite_wal(sender, connection, **kwargs):
|
|
if connection.vendor == "sqlite":
|
|
cursor = connection.cursor()
|
|
cursor.execute("PRAGMA journal_mode=WAL;")
|
|
cursor.execute("PRAGMA synchronous=OFF;")
|
|
cursor.execute("PRAGMA journal_size_limit=67108864;")
|
|
cursor.execute("PRAGMA wal_autocheckpoint=1000;")
|
|
cursor.execute("PRAGMA cache_size=-65536;")
|
|
cursor.execute("PRAGMA temp_store=MEMORY;")
|
|
cursor.execute("PRAGMA mmap_size=268435456;")
|
|
|
|
connection_created.connect(enable_sqlite_wal)
|