
# Setting Up PostgreSQL Locally and Connecting It to My Project (Beginner Journey)
Hey everyone, Today I worked on something very important in backend development — setting up a database and connecting it to my project. Until now, I was mainly focused on coding features. But today I understood that without a proper database setup, a project is not complete. So I decided to set up PostgreSQL locally and integrate it step by step. What I focused on today My main goal was to: Set up PostgreSQL locally Create a database Configure environment variables Connect database using Python Execute my database schema Step 1: Creating the database After installing PostgreSQL, I created a database for my project: ```sql id="y2y3g1" CREATE DATABASE social_media_db; This is where all my project data will be stored. --- ## Step 2: Managing credentials using .env Instead of writing database credentials directly in code, I used a `.env` file. ```env id="3hkgmq" DB_HOST=localhost DB_PORT=5432 DB_NAME=social_media_db DB_USER=postgres DB_PASSWORD=your_password This made my setup cleaner and
Continue reading on Dev.to Webdev
Opens in a new tab




