Create and connect to a Heroku PostgreSQL server by using Python in a Jupyter Notebook!
Authors: Daniel Kim & Dae Han
To examine a real-life project application of this notebook, click here on Dae's capstone. He built a time series model to forecast the total number of individuals sheltered by the NYC Department of Homeless Services (DHS).
Click here to download the Jupyter Notebook that explains how to create a Heroku account, add a PostgreSQL server, and upload a sample Pandas dataFrame to the server. The following instructions down below are found in the linked notebook above!
First, go to heroku and sign up for a free account - https://www.heroku.com/postgres
Choose a descriptive and unique App name then click "create app"
Click on this heroku add on link and click "Install Heroku Postgres"
Link the postgres add on to the app you just named.
Click on "Heroku Postgres" and go to the settings and click on the database credentials.
Note: Credentials are not permanent! There are other ways to obtain credentials, but this is just a simple example
Store the URI in a json file named creds.json
.
The format in creds.json
should be the following: {"uri" : "your-uri-credentials"}
. Take notice of the double quotations!
DO NOT UPLOAD YOUR JSON FILE ONTO GITHUB! INCLUDE THE creds.json
FILE IN THE GITIGNORE TEXT