The go-to Python library for connecting to Postgres is
psycopg2. It allows you to connect your Python script to
your database and run SQL queries from Python.
Install it by running
pip in your terminal:
pip install psycopg2
You could also use an Object-Relational Mapper (ORM) such as SQLAlchemy to run your queries.
An ORM allows you to interact with your database using Python objects rather than raw SQL code.