1
Fork 0

Tweak SQLite config

This commit is contained in:
Jake Howard 2024-10-18 18:37:37 +01:00
parent 5c8caf37c0
commit 0747768fc6
Signed by: jake
GPG key ID: 57AFB45680EDD477
2 changed files with 24 additions and 6 deletions

2
.gitignore vendored
View file

@ -63,6 +63,8 @@ cover/
*.log
local_settings.py
db.sqlite3
db.sqlite3-shm
db.sqlite3-wal
db.sqlite3-journal
# Flask stuff:

View file

@ -75,13 +75,26 @@ WSGI_APPLICATION = 'yamdl_playground.wsgi.application'
# Database
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases
db_init_command = """
PRAGMA journal_mode=OFF;
PRAGMA synchronous=OFF;
PRAGMA mmap_size = 134217728;
PRAGMA cache_size=4000;
db_init_command = f"""
PRAGMA journal_mode=WAL;
PRAGMA synchronous=NORMAL;
PRAGMA temp_store=MEMORY;
PRAGMA auto_vacuum=INCREMENTAL;
PRAGMA busy_timeout=10000;
PRAGMA threads={os.cpu_count()};
PRAGMA secure_delete=OFF;
PRAGMA mmap_size=50000000;
PRAGMA cache_size=-262144;
"""
memory_db_init_command = f"""
PRAGMA journal_mode=OFF;
PRAGMA synchronous=OFF;
PRAGMA temp_store=MEMORY;
PRAGMA auto_vacuum=INCREMENTAL;
PRAGMA busy_timeout=10000;
PRAGMA threads={os.cpu_count()};
PRAGMA secure_delete=OFF;
"""
DATABASES = {
@ -89,13 +102,16 @@ DATABASES = {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / "db.sqlite3",
"CONN_MAX_AGE": 600,
"OPTIONS": {
"init_command": db_init_command
}
},
'yamdl': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'file:yamdl-db?mode=memory&cache=shared',
"CONN_MAX_AGE": 600,
"OPTIONS": {
"init_command": db_init_command
"init_command": memory_db_init_command
}
}
}