Skip to content

GKestenberg/py-uv-db

Repository files navigation

py-uv-db

Three Python jobs for managing user data in a PostgreSQL database.

Setup

  1. Install dependencies:
uv sync
  1. Configure database connection: Copy .env.example to .env and update with your database credentials:
cp .env.example .env

Then edit .env with your actual database connection details.

Jobs

Job 1: Initialize Users Table

Creates a users table with id (auto-increment) and name columns.

uv run job1_init_table.py

Job 2: Add Users

Adds 5 random users to the database from a predefined list of 10 names.

uv run job2_add_users.py

Job 3: List Users

Displays all users in CSV format (id, name).

uv run job3_list_users.py

Example Usage

# Initialize the table
uv run job1_init_table.py

# Add users
uv run job2_add_users.py

# List users
uv run job3_list_users.py

Environment Variables

The 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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages