Examples
Basic Workflows
Section titled “Basic Workflows”Development Database Setup
Section titled “Development Database Setup”# Create and seed a development databasecreatedb myapp_devseedcli init# Edit seedcli.yaml with your connection detailsseedcli seed --all -n 50Testing Pipeline
Section titled “Testing Pipeline”# Reproducible test data in CI/CDseedcli seed --all -n 100 --seed 42Quick Prototyping
Section titled “Quick Prototyping”# Connect and seed in one commandseedcli seed --all -n 10 --db-url "postgresql://localhost/prototype"Database-Specific Examples
Section titled “Database-Specific Examples”PostgreSQL
Section titled “PostgreSQL”Local Development
Section titled “Local Development”database: adapter: postgres host: localhost port: 5432 name: myapp_dev user: postgres password: postgres ssl_mode: disableseedcli seed --all -n 100Docker PostgreSQL
Section titled “Docker PostgreSQL”database: adapter: postgres url: "postgresql://postgres:postgres@localhost:5432/myapp?sslmode=disable"Remote Database
Section titled “Remote Database”database: adapter: postgres host: db.example.com port: 5432 name: staging user: app_user password: ${DB_PASSWORD} ssl_mode: requireSQLite
Section titled “SQLite”New Database
Section titled “New Database”database: adapter: sqlite path: ./myapp.dbseedcli seed --all -n 50Existing Database
Section titled “Existing Database”database: adapter: sqlite path: /path/to/existing.dbE-commerce Example
Section titled “E-commerce Example”Schema
Section titled “Schema”-- PostgreSQL schemaCREATE TABLE users ( id SERIAL PRIMARY KEY, email VARCHAR(255) UNIQUE NOT NULL, username VARCHAR(50) UNIQUE NOT NULL, first_name VARCHAR(100), last_name VARCHAR(100), created_at TIMESTAMP DEFAULT NOW());
CREATE TABLE products ( id SERIAL PRIMARY KEY, name VARCHAR(255) NOT NULL, description TEXT, price DECIMAL(10,2) NOT NULL, sku VARCHAR(50) UNIQUE NOT NULL, category VARCHAR(50), in_stock BOOLEAN DEFAULT true);
CREATE TABLE orders ( id SERIAL PRIMARY KEY, user_id INTEGER REFERENCES users(id), status VARCHAR(20) DEFAULT 'pending', total DECIMAL(10,2), created_at TIMESTAMP DEFAULT NOW());
CREATE TABLE order_items ( id SERIAL PRIMARY KEY, order_id INTEGER REFERENCES orders(id), product_id INTEGER REFERENCES products(id), quantity INTEGER NOT NULL, price DECIMAL(10,2) NOT NULL);Configuration
Section titled “Configuration”database: adapter: postgres host: localhost name: ecommerce user: postgres password: secret
seeding: default_rows: 10 batch_size: 100
tables: users: rows: 100 columns: email: unique: true username: unique: true
products: rows: 50 columns: price: min: 9.99 max: 499.99 sku: pattern: "SKU-{A-Z}{2}-{0-9}{4}" unique: true category: values: - electronics - clothing - home - garden - sports
orders: rows: 200 columns: status: values: - pending - processing - shipped - delivered - cancelled total: min: 25.00 max: 2500.00
order_items: rows: 500 columns: quantity: min: 1 max: 10Seeding
Section titled “Seeding”# Preview data firstseedcli preview -t users -t products -n 5
# Seed all tablesseedcli seed --all
# Result:# ✅ users: 100 rows (0.45s)# ✅ products: 50 rows (0.32s)# ✅ orders: 200 rows (0.28s)# ✅ order_items: 500 rows (0.21s)CI/CD Integration
Section titled “CI/CD Integration”GitHub Actions
Section titled “GitHub Actions”name: Test
on: [push, pull_request]
jobs: test: runs-on: ubuntu-latest
services: postgres: image: postgres:15 env: POSTGRES_PASSWORD: postgres options: >- --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 ports: - 5432:5432
steps: - uses: actions/checkout@v4
- uses: actions/setup-go@v5 with: go-version: '1.21'
- name: Install seedcli run: go install github.com/kiridharan/seedcli@latest
- name: Setup database run: | PGPASSWORD=postgres psql -h localhost -U postgres -c "CREATE DATABASE test_db" PGPASSWORD=postgres psql -h localhost -U postgres -d test_db -f schema.sql
- name: Seed database run: | seedcli seed --all -n 100 --seed 42 \ --db-url "postgresql://postgres:postgres@localhost:5432/test_db?sslmode=disable"
- name: Run tests run: go test ./...Docker Compose
Section titled “Docker Compose”version: '3.8'
services: db: image: postgres:15 environment: POSTGRES_DB: myapp POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres volumes: - ./schema.sql:/docker-entrypoint-initdb.d/schema.sql healthcheck: test: ["CMD-SHELL", "pg_isready -U postgres"] interval: 5s timeout: 5s retries: 5
seed: image: golang:1.21 depends_on: db: condition: service_healthy volumes: - ./seedcli.yaml:/app/seedcli.yaml working_dir: /app command: > sh -c "go install github.com/kiridharan/seedcli@latest && seedcli seed --all -n 100" environment: DB_HOST: db# seedcli.yaml for Dockerdatabase: adapter: postgres host: ${DB_HOST:-localhost} port: 5432 name: myapp user: postgres password: postgresPerformance Tuning
Section titled “Performance Tuning”Large Datasets
Section titled “Large Datasets”# Seed 100,000 rows with large batchesseedcli seed --all -n 100000 --batch-size 5000Disable Foreign Keys
Section titled “Disable Foreign Keys”For faster seeding (use with caution):
seedcli seed --all -n 50000 --disable-fk --batch-size 2000Truncate Before Seeding
Section titled “Truncate Before Seeding”# Clear existing data firstseedcli seed --all -n 1000 --truncateTroubleshooting
Section titled “Troubleshooting”Connection Issues
Section titled “Connection Issues”# Test connectionseedcli list --db-url "postgresql://localhost/mydb"
# Check logscat .logseed/seedcli-*.log | tail -50Constraint Violations
Section titled “Constraint Violations”# Skip errors and continueseedcli seed --all --skip-errors
# Or use dry-run to debugseedcli seed --all --dry-runForeign Key Errors
Section titled “Foreign Key Errors”# Disable FK checks temporarilyseedcli seed --all --disable-fk