import MySQLdb
import urlparse
import os

urlparse.uses_netloc.append('mysql')

try:
    if 'DATABASES' not in locals():
        DATABASES = {}

    if 'DATABASE_URL' in os.environ:
        url = urlparse.urlparse(os.environ['DATABASE_URL'])

        # Ensure default database exists.
        DATABASES['default'] = DATABASES.get('default', {})

        # Update with environment configuration.
        DATABASES['default'].update({
            'NAME': url.path[1:],
            'USER': url.username,
            'PASSWORD': url.password,
            'HOST': url.hostname,
            'PORT': url.port,
        })


        if url.scheme == 'mysql':
            DATABASES['default']['ENGINE'] = 'django.db.backends.mysql'
except Exception:
    print 'Unexpected error:', sys.exc_info()


def connection():
    conn = MySQLdb.connect(host=DATABASES['HOST'],
                           user=DATABASES['USER'],
                           passwd=DATABASES['PASSWORD'],
                           db=DATABASES['NAME']
                           )
    # conn = MySQLdb.connect(host="localhost",
    #                        user="root",
    #                        passwd="gichin124",
    #                        db="tripmeal")
    c = conn.cursor()
    return c, conn

import MySQLdb


def connection():
    conn = MySQLdb.connect(host="localhost",
                           user="root",
                           passwd="gichin124",
                           db="tripmeal")
    c = conn.cursor()
    return c, conn

--- 
+++ 
@@ -1,10 +1,44 @@
 import MySQLdb
+import urlparse
+import os
+
+urlparse.uses_netloc.append('mysql')
+
+try:
+    if 'DATABASES' not in locals():
+        DATABASES = {}
+
+    if 'DATABASE_URL' in os.environ:
+        url = urlparse.urlparse(os.environ['DATABASE_URL'])
+
+        # Ensure default database exists.
+        DATABASES['default'] = DATABASES.get('default', {})
+
+        # Update with environment configuration.
+        DATABASES['default'].update({
+            'NAME': url.path[1:],
+            'USER': url.username,
+            'PASSWORD': url.password,
+            'HOST': url.hostname,
+            'PORT': url.port,
+        })
+
+
+        if url.scheme == 'mysql':
+            DATABASES['default']['ENGINE'] = 'django.db.backends.mysql'
+except Exception:
+    print 'Unexpected error:', sys.exc_info()
 
 
 def connection():
-    conn = MySQLdb.connect(host="localhost",
-                           user="root",
-                           passwd="gichin124",
-                           db="tripmeal")
+    conn = MySQLdb.connect(host=DATABASES['HOST'],
+                           user=DATABASES['USER'],
+                           passwd=DATABASES['PASSWORD'],
+                           db=DATABASES['NAME']
+                           )
+    # conn = MySQLdb.connect(host="localhost",
+    #                        user="root",
+    #                        passwd="gichin124",
+    #                        db="tripmeal")
     c = conn.cursor()
     return c, conn
Add the new settings for the database
