Skip to content

Switch from SQLite to PostgreSQL with .env config #10

Description

@Navashub

Description

SQLite is great for development but not production. Migrate the database connection to PostgreSQL, with the URL read from an environment variable.

What to do

  • Add pip install psycopg2-binary python-dotenv to dependencies
  • Create a .env file (and add it to .gitignore): DATABASE_URL=postgresql://user:password@localhost/devboard
  • Update database.py to read DATABASE_URL from the environment using os.getenv or python-dotenv
  • Create a .env.example file with placeholder values for other contributors
  • Update the README with instructions for setting up PostgreSQL locally (including a Docker one-liner)

Acceptance Criteria

  • The app runs with a PostgreSQL database when DATABASE_URL is set
  • Falls back gracefully or raises a clear error if DATABASE_URL is missing
  • .env is in .gitignore and never committed
  • .env.example is committed and documents required variables

Docker one-liner for reviewers:

docker run --name devboard-pg -e POSTGRES_PASSWORD=password -e POSTGRES_DB=devboard -p 5432:5432 -d postgres

Difficulty

🟡 Intermediate

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendPython / FastAPI workdevopsDocker, PostgreSQL, deploymentintermediateRequires some FastAPI experience

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions