P
💻DeveloppementBeginnerChatGPT

Install and configure PostgreSQL for a project

Install and configure PostgreSQL from scratch with database creation, users, connection from your application and first SQL queries.

Paste in your AI

Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.

Tu es un formateur en développement web spécialisé dans les bases de données pour débutants. Je dois installer et configurer PostgreSQL pour mon premier projet et je ne sais pas par où commencer.

**Mon contexte :**
- OS : [EX: macOS avec Homebrew, Ubuntu 22.04, Windows 11]
- Projet : [EX: application Node.js avec Express, application Python avec Django, application React]
- Objectif : [EX: développement local uniquement, préparation pour le déploiement]

Guide-moi étape par étape :

1. **Installation** : commandes exactes pour installer PostgreSQL sur mon OS. Explique ce qui est installé et pourquoi.

2. **Premiers pas avec psql** : comment démarrer le service, me connecter avec psql, les commandes de base (\l, \c, \dt, \d table).

3. **Créer ma base de données** : créer une base de données et un utilisateur dédié pour mon projet (pas utiliser postgres en production), avec les permissions appropriées.

4. **Créer mes premières tables** : une ou deux tables simples avec les types de données courants (VARCHAR, INTEGER, BOOLEAN, TIMESTAMP, TEXT), les contraintes (NOT NULL, UNIQUE, PRIMARY KEY, FOREIGN KEY).

5. **Connexion depuis mon application** : montre comment connecter PostgreSQL depuis [Node.js avec pg ou Prisma / Python avec psycopg2 ou SQLAlchemy] avec les bonnes pratiques (pool de connexions, variables d'environnement).

6. **Sécurité basique** : mots de passe forts, ne jamais exposer PostgreSQL sur internet, .env pour les credentials.

7. **Commandes utiles** : les 10 commandes SQL les plus utiles pour débuter (SELECT, INSERT, UPDATE, DELETE, JOIN simple).

Explique chaque étape clairement et indique les erreurs courantes à éviter.

Why this prompt works

<p>This prompt is calibrated for complete beginners with PostgreSQL by asking for explanations on each command, not just the syntax. Creating a dedicated user for the project (rather than using the postgres superuser) is a fundamental security best practice that beginner tutorials often omit.</p><p>Integrating the connection from the application in the same prompt is valuable because this is the step where beginners get stuck most often: having the database installed and configured is useless if you don't know how to connect to it from your code.</p><p>The basic security section, even simplified for beginners, establishes good habits from the start: never hardcode credentials in the code, never expose the PostgreSQL port publicly. These habits adopted early in learning prevent costly security incidents later.</p>

Use Cases

First PostgreSQL installationDatabase setup for personal projectSQL and database training

Expected Output

Complete installation guide with exact commands, secure configuration, database and table creation, connection from application and basic SQL commands.

Learn more

Check the full skill on Prompt Guide to master this technique from A to Z.

View on Prompt Guide