#24018: Support journal_mode=WAL for sqlite -------------------------------------+------------------------------------- Reporter: Curtis Maloney | Owner: Aaron | Linville Type: New feature | Status: assigned Component: Database layer | Version: dev (models, ORM) | Severity: Normal | Resolution: Keywords: | Triage Stage: Accepted Has patch: 1 | Needs documentation: 1 Needs tests: 0 | Patch needs improvement: 1 Easy pickings: 0 | UI/UX: 0 -------------------------------------+-------------------------------------
Comment (by Afonso Silva): Based on the previous answers, a workaround for allowing `init_command` similar to MySQL is to use a signal receiver for `connection_created`, e.g.: {{{#!python from django.conf import settings from django.db.backends.signals import connection_created from django.dispatcher import receiver @receiver(connection_created) def init_command(sender, connection, **kwargs) -> None: command = connection.settings_dict["OPTIONS"].get("init_command") if connection.vendor == "sqlite" and command: cursor = connection.cursor() cursor.execute(command) }}} This way you could add `init_command` to your `settings.py`: {{{#!python DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': BASE_DIR / 'db.sqlite3', 'OPTIONS': { 'init_command': 'PRAGMA journal_mode=wal;' } } } }}} I think having this natively in Django would be useful, is there any help needed for the previous linked PR? -- Ticket URL: <https://code.djangoproject.com/ticket/24018#comment:9> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/0107018a02f0b11d-7d104f2c-c442-4d9f-8b40-e9a5b49a4776-000000%40eu-central-1.amazonses.com.