Make Sqlite3 PRAGMAs customizable from settings

This commit is contained in:
Griatch 2024-08-16 11:53:34 +02:00
parent 3e006cff1a
commit 6f255c9ff8
3 changed files with 25 additions and 16 deletions

View file

@ -2,15 +2,16 @@
## Main branch ## Main branch
Feat: Support `scripts key:typeclass` form to create global scripts - Feat: Support `scripts key:typeclass` to create global scripts
with dynamic keys (rather than just relying on typeclass' key). Support with dynamic keys (rather than just relying on typeclass' key) (Griatch)
searching using the same syntax (Griatch) - [Feat][pull3595]: Tweak Sqlite3 PRAGMAs for better performance (0xDEADFED5)
[Fix][issue3556]: Better error if trying to treat ObjectDB as a typeclass (Griatch) - Feat: Make Sqlite3 PRAGMAs configurable via settings (Griatch)
[Fix][issue3590]: Make `examine` command properly show `strattr` type - [Fix][issue3556]: Better error if trying to treat ObjectDB as a typeclass (Griatch)
- [Fix][issue3590]: Make `examine` command properly show `strattr` type
Attribute values (Griatch) Attribute values (Griatch)
[Fix][issue3519]: `GLOBAL_SCRIPTS` container didn't list global scripts not - [Fix][issue3519]: `GLOBAL_SCRIPTS` container didn't list global scripts not
defined explicitly to be restarted/recrated in settings.py (Griatch) defined explicitly to be restarted/recrated in settings.py (Griatch)
Fix: Passing an already instantiated Script to `obj.scripts.add` (`ScriptHandler.add`) - Fix: Passing an already instantiated Script to `obj.scripts.add` (`ScriptHandler.add`)
did not add it to the handler's object (Griatch) did not add it to the handler's object (Griatch)
[Docs][issue3591]: Fix of NPC reaction tutorial code (Griatch) [Docs][issue3591]: Fix of NPC reaction tutorial code (Griatch)
@ -18,6 +19,7 @@ did not add it to the handler's object (Griatch)
[issue3590]: https://github.com/evennia/evennia/issues/3590 [issue3590]: https://github.com/evennia/evennia/issues/3590
[issue3556]: https://github.com/evennia/evennia/issues/3556 [issue3556]: https://github.com/evennia/evennia/issues/3556
[issue3519]: https://github.com/evennia/evennia/issues/3519 [issue3519]: https://github.com/evennia/evennia/issues/3519
[pull3595]: https://github.com/evennia/evennia/pull/3595
## Evennia 4.3.0 ## Evennia 4.3.0

View file

@ -8,20 +8,19 @@ import time
import traceback import traceback
import django import django
import evennia
from django.conf import settings from django.conf import settings
from django.db import connection from django.db import connection
from django.db.utils import OperationalError from django.db.utils import OperationalError
from django.utils.translation import gettext as _ from django.utils.translation import gettext as _
from evennia.utils import logger
from evennia.utils.utils import get_evennia_version, make_iter, mod_import
from twisted.application import internet from twisted.application import internet
from twisted.application.service import MultiService from twisted.application.service import MultiService
from twisted.internet import defer, reactor from twisted.internet import defer, reactor
from twisted.internet.defer import Deferred from twisted.internet.defer import Deferred
from twisted.internet.task import LoopingCall from twisted.internet.task import LoopingCall
import evennia
from evennia.utils import logger
from evennia.utils.utils import get_evennia_version, make_iter, mod_import
_SA = object.__setattr__ _SA = object.__setattr__
@ -282,12 +281,10 @@ class EvenniaServerService(MultiService):
and settings.DATABASES.get("default", {}).get("ENGINE", None) and settings.DATABASES.get("default", {}).get("ENGINE", None)
== "django.db.backends.sqlite3" == "django.db.backends.sqlite3"
): ):
# sqlite3 database pragmas (directives)
cursor = connection.cursor() cursor = connection.cursor()
cursor.execute("PRAGMA cache_size=10000") for pragma in settings.SQLITE3_PRAGMAS:
cursor.execute("PRAGMA synchronous=1") cursor.execute(pragma)
cursor.execute("PRAGMA count_changes=OFF")
cursor.execute("PRAGMA temp_store=2")
cursor.execute("PRAGMA journal_mode=WAL")
def update_defaults(self): def update_defaults(self):
""" """

View file

@ -300,6 +300,16 @@ DATABASES = {
"PORT": "", "PORT": "",
} }
} }
# PRAGMA (directives) for the default Sqlite3 database operations. This can be used to tweak
# performance for your setup. Don't change this unless you know what # you are doing.
SQLITE3_PRAGMAS = (
"PRAGMA cache_size=10000",
"PRAGMA synchronous=1",
"PRAGMA count_changes=OFF",
"PRAGMA temp_store=2",
"PRAGMA journal_mode=WAL",
)
# How long the django-database connection should be kept open, in seconds. # How long the django-database connection should be kept open, in seconds.
# If you get errors about the database having gone away after long idle # If you get errors about the database having gone away after long idle
# periods, shorten this value (e.g. MySQL defaults to a timeout of 8 hrs) # periods, shorten this value (e.g. MySQL defaults to a timeout of 8 hrs)