brutaldon/brutaldon/__init__.py

14 lines
690 B
Python

from django.db.backends.signals import connection_created
def configure_sqlite_web_settings(sender, connection, **kwargs):
"""Configure sqlite for web application use."""
if connection.vendor == 'sqlite':
cursor = connection.cursor()
cursor.execute('PRAGMA journal_mode = WAL;')
cursor.execute('PRAGMA synchronous = NORMAL;')
cursor.execute('PRAGMA journal_size_limit = 67108864; -- 64 megabytes')
cursor.execute('PRAGMA mmap_size = 134217728; -- 128 megabytes')
cursor.execute('PRAGMA cache_size = 2000; -- 2000 pages')
cursor.execute('PRAGMA busy_timeout = 5000;')
connection_created.connect(configure_sqlite_web_settings)