Skip to content

Instantly share code, notes, and snippets.

@justhamade
Created July 31, 2013 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justhamade/6123980 to your computer and use it in GitHub Desktop.
Save justhamade/6123980 to your computer and use it in GitHub Desktop.
Stackato Example settings.py
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