Three Python jobs for managing user data in a PostgreSQL database.
- Install dependencies:
uv sync- Configure database connection:
Copy
.env.exampleto.envand update with your database credentials:
cp .env.example .envThen edit .env with your actual database connection details.
Creates a users table with id (auto-increment) and name columns.
uv run job1_init_table.pyAdds 5 random users to the database from a predefined list of 10 names.
uv run job2_add_users.pyDisplays all users in CSV format (id, name).
uv run job3_list_users.py# Initialize the table
uv run job1_init_table.py
# Add users
uv run job2_add_users.py
# List users
uv run job3_list_users.pyThe jobs support two connection methods:
Option 1: Connection URL (recommended)
DB_URL=postgresql://username:password@localhost:5432/database_name
Option 2: Individual parameters
DB_HOST=localhost
DB_NAME=database_name
DB_PORT=5432
DB_USER=username
DB_PASS=password