PostgreSQL is a powerful, open source object-relational database system with over 30 years of active development that has earned it a strong reputation for reliability, feature robustness, and performance. PostgreSQL docs
Installation
Docker Compose
Docker Compose setup is recommended for a more organized and scalable environment.
init.sql
The init.sql file at the root of the project will be executed when the container starts, initializing the database with the content of the file.
Python Integration
Installation
Installation in venv:
Usage
Using the psycopg2 library to connect to a PostgreSQL database. Getting the address, user, password and database from the environment variables for safety. The database used in this example is the one created in init.sql.
Environment Variables
Create a .env file at the root of the project with the following content: