From: Benjamin Diaz Date: Fri, 24 May 2019 20:54:48 +0000 (-0300) Subject: Enables use of mysql database as backend for session storage X-Git-Tag: v6.0.0~6 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F48%2F7548%2F1;p=osm%2FLW-UI.git Enables use of mysql database as backend for session storage Depends-On: I52d1ef046d2c3804f305c57f8d35889dd1f038f7 Change-Id: Idc2b43f09cc749c2ef160bc4440e9a6dbddc5167 Signed-off-by: Benjamin Diaz --- diff --git a/sf_t3d/settings.py b/sf_t3d/settings.py index d000e65..768152a 100644 --- a/sf_t3d/settings.py +++ b/sf_t3d/settings.py @@ -15,6 +15,7 @@ # import os +from sqlalchemy.engine.url import make_url # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) @@ -125,12 +126,26 @@ WSGI_APPLICATION = 'sf_t3d.wsgi.application' # Database # https://docs.djangoproject.com/en/1.9/ref/settings/#databases -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), +sql_uri = make_url(os.getenv('OSMUI_SQL_DATABASE_URI', 'sqlite:///db.sqlite3')) +if 'sqlite' in sql_uri.drivername: + DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, sql_uri.database if sql_uri.database else 'db.sqlite3'), + } } -} +else: + DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.mysql', + 'NAME': sql_uri.database if sql_uri.database else 'lwui', + 'USER': sql_uri.username, + 'PASSWORD': sql_uri.password, + 'HOST': sql_uri.host, + 'PORT': sql_uri.port, + } + } + AUTHENTICATION_BACKENDS = ['authosm.backend.OsmBackend']