Created
July 31, 2013 17:07
-
-
Save justhamade/6123980 to your computer and use it in GitHub Desktop.
Stackato Example settings.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urlparse | |
DATABASES = {} | |
if 'DATABASE_URL' in os.environ: | |
url = urlparse.urlparse(os.environ['DATABASE_URL']) | |
DATABASES['default'] = { | |
'NAME': url.path[1:], | |
'USER': url.username, | |
'PASSWORD': url.password, | |
'HOST': url.hostname, | |
'PORT': url.port, | |
} | |
if url.scheme == 'postgres': | |
DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql_psycopg2' | |
elif url.scheme == 'mysql': | |
DATABASES['default']['ENGINE'] = 'django.db.backends.mysql' | |
else: | |
DATABASES['default'] = { | |
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. | |
'NAME': 'dev.db', # Or path to database file if using sqlite3. | |
'USER': '', # Not used with sqlite3. | |
'PASSWORD': '', # Not used with sqlite3. | |
'HOST': '', # Set to empty string for localhost. Not used with sqlite3. | |
'PORT': '', # Set to empty string for default. Not used with sqlite3. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment