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.
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: