Skip to content

Commit

Permalink
optimization for sqlite db-connection (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
ansibleguy committed Mar 1, 2024
1 parent 4daac0c commit 99c88d9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ jobs:
echo 'API INTEGRATION TESTS'
echo 'Create API key'
api_key="$(python3 src/ansibleguy-webui/cli.py -f api-key -a create -p "$AW_ADMIN" | grep 'Key=' | cut -d '=' -f2)"
api_key="$(python3 src/ansibleguy-webui/cli.py -a api-key.create -p "$AW_ADMIN" | grep 'Key=' | cut -d '=' -f2)"
export AW_API_KEY="$api_key"
sleep 1
python3 test/integration/api/main.py
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## Version 0

### 0.0.14

* SQLite connection optimizations
* Database version-upgrade enhancements

----

### 0.0.13

* Multiple UI improvements
Expand Down
15 changes: 15 additions & 0 deletions src/ansibleguy-webui/aw/apps.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
from django.apps import AppConfig
from django.dispatch import receiver
from django.db.backends.signals import connection_created


class AwConfig(AppConfig):
name = 'aw'
verbose_name = 'Ansible-WebUI'


# configuring sqlite at application startup/connection initialization
@receiver(connection_created)
def configure_sqlite(connection, **kwargs):
if connection.vendor == 'sqlite':
with connection.cursor() as cursor:
# https://www.sqlite.org/pragma.html#pragma_journal_mode
cursor.execute('PRAGMA journal_mode = WAL;')
# https://www.sqlite.org/pragma.html#pragma_busy_timeout
cursor.execute('PRAGMA busy_timeout = 5000;')
# https://www.sqlite.org/pragma.html#pragma_synchronous
cursor.execute('PRAGMA synchronous = NORMAL;')

0 comments on commit 99c88d9

Please # to comment.