I'm having trouble using the following lines of code from https://devcenter.heroku.com/articles/heroku-postgresql#connecting-in-python
import os
import psycopg2
import urlparse
urlparse.uses_netloc.append("postgres")
url = urlparse.urlparse(os.environ["DATABASE_URL"])
conn = psycopg2.connect(
database=url.path[1:],
user=url.username,
password=url.password,
host=url.hostname,
port=url.port
)
I'm using Python 3.6.2
In my Heroku logs I'm seeing:
ModuleNotFoundError: No module named 'urlparse'
Any help would be much appreciated!!