Exemple #1
0
def postgresql_db_config(host, username, password):
    """
    generates a Django DATABASE configuration dict containing all
    postgresql databases.
    """
    databases = {}
    for name in postgres_list(host, username, password):
        databases["postgres_" + name] = {
            'ENGINE': 'django.db.backends.postgresql_psycopg2',
            'NAME': name,
            'USER': name,
            'PASSWORD': name,
            'CONSOLE': True,
        }
    return databases
Exemple #2
0
# below is an example autoconfigure setup. It will probe PostgreSQL and
# MonetDB database servers, and will add all databases existing on these
# servers to the django database configuration. You don't have to configure
# banana like this! You can also just add the database by hand.
#
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases
#
MONETDB_HOST = 'localhost'
MONETDB_PORT = 50000
MONETDB_PASSPHRASE = 'blablabla'

POSTGRES_HOST = 'localhost'
POSTGRES_USERNAME = '******'
POSTGRES_PASSWORD = POSTGRES_USERNAME

for name in postgres_list(POSTGRES_HOST, POSTGRES_USERNAME, POSTGRES_PASSWORD):
    # django reverse url mapping can't handle non aplhanum chars
    config_name = ("postgres_" + re.sub(r'\W+', '', name))
    DATABASES["postgres_" + name] = {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'HOST': POSTGRES_HOST,
        'NAME': name,
        'USER': name,
        'PASSWORD': name,
    }


# mongodb is used for image storage.
MONGODB = {
    "enabled": True,
    "host": "localhost",