Lab: postgres and python using psycopg2

Nothing to hand in

To access a PostgreSQL database from a Python program, we will use the psycopg2 module. This short exercise is intended to get you ready to use psycopg2 when you start developing your own database-driven application.

Things to do

Note: I'm going to assume you will do this lab on stearns. If you have installed postgres on your computer, that's fine, but then you'll also have to install the psycopg2 python module in your global installation of python3 or your virtual environment.

Recap

Once you have the sample program working, reread the code to nail down in your brain this basic sequence of steps involved in querying your database from your code: