From 75beb917914eb929ebc1cad35c06c7bb32453be9 Mon Sep 17 00:00:00 2001 From: Jonas Winkler Date: Sun, 15 Jul 2018 13:40:38 +0200 Subject: [PATCH] added options to change database backend --- paperless.conf.example | 10 ++++++++++ src/documents/checks.py | 4 ++-- src/paperless/settings.py | 4 ++-- 3 files changed, 14 insertions(+), 4 deletions(-) mode change 100644 => 100755 paperless.conf.example mode change 100644 => 100755 src/documents/checks.py diff --git a/paperless.conf.example b/paperless.conf.example old mode 100644 new mode 100755 index 3d90b2915..043ffa5c7 --- a/paperless.conf.example +++ b/paperless.conf.example @@ -3,6 +3,16 @@ # As this file contains passwords it should only be readable by the user # running paperless. +############################################################################### +#### Database Settings #### +############################################################################### + +# By default, sqlite is used as the database backend. This can be changed here. +#PAPERLESS_DBENGINE="django.db.backends.postgresql_psycopg2" +#PAPERLESS_DBNAME="paperless" +#PAPERLESS_DBUSER="paperless" +#PAPERLESS_DBPASS="paperless" + ############################################################################### #### Paths & Folders #### diff --git a/src/documents/checks.py b/src/documents/checks.py old mode 100644 new mode 100755 index c80b63863..3310b1806 --- a/src/documents/checks.py +++ b/src/documents/checks.py @@ -2,7 +2,7 @@ import textwrap from django.conf import settings from django.core.checks import Error, register -from django.db.utils import OperationalError +from django.db.utils import OperationalError, ProgrammingError @register() @@ -14,7 +14,7 @@ def changed_password_check(app_configs, **kwargs): try: encrypted_doc = Document.objects.filter( storage_type=Document.STORAGE_TYPE_GPG).first() - except OperationalError: + except (OperationalError, ProgrammingError): return [] # No documents table yet if encrypted_doc: diff --git a/src/paperless/settings.py b/src/paperless/settings.py index 9feb7860f..98e9eea7f 100755 --- a/src/paperless/settings.py +++ b/src/paperless/settings.py @@ -133,9 +133,9 @@ DATABASES = { } } -if os.getenv("PAPERLESS_DBUSER") and os.getenv("PAPERLESS_DBPASS"): +if os.getenv("PAPERLESS_DBENGINE"): DATABASES["default"] = { - "ENGINE": "django.db.backends.postgresql_psycopg2", + "ENGINE": os.getenv("PAPERLESS_DBENGINE"), "NAME": os.getenv("PAPERLESS_DBNAME", "paperless"), "USER": os.getenv("PAPERLESS_DBUSER"), "PASSWORD": os.getenv("PAPERLESS_DBPASS")