Using psycopg2

The steps below will walk you through connecting to Postgres using psycopg2.


1. Open a notebook.

If you're not already logged in, follow the steps found here. In the upper-right corner, click the New button and select compute (or any kernel that has psycopg2 installed).


2. Connect to the 'cusp' database

In the first cell, copy and paste the following code to create a connection to the cusp Postgres database.

import psycopg2

conn = psycopg2.connect("host=stuffed dbname=cusp")

You can use the conn connection to query the cusp database. For examples on how to use psycopg2, check out this Psycopg2 Tutorial.