Skip to content

Commit

Permalink
trying database settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Ederporto committed Sep 23, 2023
1 parent cb24501 commit 207d56d
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions sara/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,14 @@
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.1/ref/settings/
"""

import os
from pathlib import Path
import configparser
import os
from django.utils.translation import gettext_lazy as _

# SECURITY WARNING: keep the secret key used in production secret!
# SECURITY WARNING: don't run with debug turned on in production!
from .settings_local import *


# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent

Expand Down Expand Up @@ -82,25 +79,30 @@
# Database
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases


HOME = os.environ.get('HOME')
replica_path = HOME + '/replica.my.cnf'
if os.path.exists(replica_path):
config = configparser.ConfigParser()
config.read(replica_path)
else:
print('replica.my.cnf file not found')

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 's55346__saradb',
'USER': config['client']['user'],
'PASSWORD': config['client']['password'],
'HOST': 'tools.db.svc.wikimedia.cloud',
'PORT': '',
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# HOME = os.environ.get('HOME')
# replica_path = HOME + '/replica.my.cnf'
# if os.path.exists(replica_path):
# config = configparser.ConfigParser()
# config.read(replica_path)
# else:
# print('replica.my.cnf file not found')
#
# DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.mysql',
# 'NAME': 's55346__saradb',
# 'USER': config['client']['user'],
# 'PASSWORD': config['client']['password'],
# 'HOST': 'tools.db.svc.wikimedia.cloud',
# 'PORT': '',
# }
# }

# Password validation
# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators
Expand Down Expand Up @@ -144,10 +146,9 @@
# https://docs.djangoproject.com/en/4.1/howto/static-files/

STATIC_URL = 'static/'
# STATICFILES_DIRS = (
# os.path.join(BASE_DIR, 'static'),
# )
# STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'))
STATIC_ROOT = os.path.join(BASE_DIR, 'static')

# Default primary key field type
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field

Expand Down

0 comments on commit 207d56d

Please sign in to comment.