diff --git a/.gitignore b/.gitignore index 73ef8ca..a8cf95d 100644 --- a/.gitignore +++ b/.gitignore @@ -114,3 +114,5 @@ node_modules .vscode package-lock.json yarn.lock +/db.sqlite3-* + diff --git a/brutaldon/__init__.py b/brutaldon/__init__.py index e69de29..b637806 100644 --- a/brutaldon/__init__.py +++ b/brutaldon/__init__.py @@ -0,0 +1,13 @@ +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)