
Note: You can do everything we’re about to do with Psycopg2 alone, but SQLAlchemy (which is dependent on Psycopg2) makes things a bit easier when working in python.
#PYTHON CONNECT TO POSTGRESQL HOW TO#
This article will show you how to connect any PostgreSQL database to a local Jupyter notebook. To follow along, get the Jupyter notebook here.


When connected to remote data sources -such as a Postgres database running on an AWS instance or Panoply’s data warehouse -Jupyter notebooks can become powerful tools for streamlining, documenting and replicating your data analysis workflow. Jupyter allows you to write code, add text and images, analyze data and generate visualizations all in one simple, easy-to-use interface. Jupyter notebooks have quickly become one of the most popular, if not the most popular way, to write and share code in the data science and analytics community.
