Reputation: 16405
I am exploring various features of the Python language. I have created a Postgres db on Heroku, am am looking to connect to it. I have the host, database user, port and password settings. I am not looking to deploy to Heroku, just connect locally to this db. Where can I get started?
Upvotes: 3
Views: 4600
Reputation: 1339
From Heroku Postgres doc, with psycopg2
:
To use PostgreSQL as your database in Python applications you will need to use the psycopg2 package.
pip install psycopg2-binary
And use this package to connect to DATABASE_URL in your code.
import os import psycopg2 DATABASE_URL = os.environ['DATABASE_URL'] conn = psycopg2.connect(DATABASE_URL, sslmode='require')
Upvotes: 10
Reputation: 1099
I don't know anything about Heroku, but maybe psycopg is what you're looking for?
Upvotes: 1