Running PostgreSQL
🏠The everyday picture
You can visit a records office in town (a managed service), or set up a small one in your own house for practice (a local install).
📘What it really is
Three ways to get a PostgreSQL to practise on:
- Docker (the same everywhere; Level 6 teaches Docker fully):
docker run --name crm-db -e POSTGRES_PASSWORD=devpassword -p 5432:5432 -d postgres:17
- Installers: Postgres.app on Mac, the EDB installer on Windows, or your Linux package manager.
-
A managed free tier (Supabase or Neon): nothing to install; you get a connection string.
-
A connection string holds everything needed to connect:
postgresql://user:password@host:5432/databaseIt contains a password: keep it in.envasDATABASE_URL, never in code or Git. -
Managed services require TLS (encrypted connections); add
?sslmode=requireif needed. - One server holds several databases; each database has schemas (namespaces,
publicby default) holding tables. - Create a database for your CRM:
CREATE DATABASE crm;
🖱️Try it
Get PostgreSQL running by one of the three ways. Create a database called crm. Put the connection string in your API
project's .env as DATABASE_URL and the variable name (with a placeholder) in .env.example.
✅Quick check
Where should the database connection string be kept?
Show the answer
In an environment variable (like DATABASE_URL in .env), never in code or Git, because it contains a password.
What's a schema in PostgreSQL?
Show the answer
A namespace inside a database that holds tables; public is the default.
