summaryrefslogtreecommitdiff
path: root/ql/settings.py
blob: 7d8af00f0d4e0d6ea1b6c608005f6625de655d16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import json, os, sys

def _fetch_settings(config_path, constant_config, default_config):
    try:
        config = constant_config.copy()
        config.update(json.load(open(config_path)))
        return config
    except FileNotFoundError:
        with open(config_path, 'w') as new_config:
            json.dump(default_config, new_config)
        print(
            'Config file %s created, fill it up!' %
            os.path.realpath(config_path)
        )
        sys.exit()
    except ValueError:
        print(
            'Config file %s invalid, fix it!' %
            os.path.realpath(config_path)
        )
        sys.exit(1)

DATABASES = {
    'default': _fetch_settings(
        'config.json',
        {
            'ENGINE': 'mysql.connector.django'
        },
        {
            'HOST': 'localhost',
            'PORT': '3306',
            'USER': 'root',
            'PASSWORD': '',
            'NAME': 'belongs_to_us'
        }
    )
}

INSTALLED_APPS = (
    'ql.orm',
)

SECRET_KEY = 'f5a73e42-a600-4925-a860-b40b72acf497'