tinyetl 0.12.0

Fast, zero-config ETL in a single binary for transforming data between formats and databases
# TinyETL Test Environment

This Docker Compose setup provides database and HTTP server instances for testing TinyETL functionality.

## Services

| Service     | Port  | Database/Purpose | Username | Password/Token |
|-------------|-------|------------------|----------|----------------|
| PostgreSQL  | 5432  | testdb           | testuser | testpass |
| MySQL       | 3306  | testdb           | testuser | testpass |
| MongoDB     | 27017 | testdb           | testuser | testpass |
| HTTP Server | 8680  | Test API         | testuser | testpass / test-bearer-token-12345 |

## Quick Start

```bash
# Start all services
docker-compose up -d

# Check service status
docker-compose ps

# View logs
docker-compose logs [service-name]

# Stop all services
docker-compose down

# Stop and remove volumes (clean slate)
docker-compose down -v
```

## Connection Strings for TinyETL

```bash
# PostgreSQL
tinyetl source.csv "postgres://testuser:testpass@localhost:5432/testdb#employees"

# MySQL
tinyetl source.csv "mysql://testuser:testpass@localhost:3306/testdb#employees"

# SQLite (for comparison)
tinyetl source.csv "sqlite://./test.db#employees"
```

## Manual Database Access

### PostgreSQL
```bash
# Connect using psql
docker exec -it tinyetl-postgres psql -U testuser -d testdb

# Or from host (requires psql client)
psql -h localhost -U testuser -d testdb
```

### MySQL
```bash
# Connect using mysql client
docker exec -it tinyetl-mysql mysql -u testuser -ptestpass testdb

# Or from host (requires mysql client)
mysql -h localhost -u testuser -ptestpass testdb
```

### MongoDB
```bash
# Connect using mongosh
docker exec -it tinyetl-mongodb mongosh --username testuser --password testpass --authenticationDatabase admin testdb

# Or from host (requires mongosh client)
mongosh "mongodb://testuser:testpass@localhost:27017/testdb?authSource=admin"
```

## Sample Data

Each database is initialized with sample `employees` and `products` tables/collections:

- **employees**: id, first_name, last_name, email, department, salary, hire_date
- **products**: id, name, category, price, stock_quantity, created_at

## Testing TinyETL Examples

```bash
# Test PostgreSQL connection (from tinyetl root)
cargo run -- examples/05_csv_to_sqlite/employees.csv "postgres://testuser:testpass@localhost:5432/testdb#test_employees" --dry-run

# Test MySQL connection
cargo run -- examples/07_csv_to_mysql/customers.csv "mysql://testuser:testpass@localhost:3306/testdb#test_customers" --dry-run

# Actual data transfer (remove --dry-run)
cargo run -- examples/05_csv_to_sqlite/employees.csv "postgres://testuser:testpass@localhost:5432/testdb#test_employees"
```

## HTTP Server for Protocol Testing

The HTTP server provides endpoints for testing TinyETL's HTTP protocol with various authentication methods:

```bash
# Start the HTTP server
docker-compose up -d http-server

# Run automated tests
cd http-server
./test.sh

# Test endpoints manually
curl http://localhost:8680/health
curl http://localhost:8680/public/data.csv
curl -u testuser:testpass http://localhost:8680/basic-auth/users.csv
curl -H "Authorization: Bearer test-bearer-token-12345" http://localhost:8680/bearer-auth/products.csv
```

See [`http-server/README.md`](http-server/README.md) for detailed documentation.

## S3 Protocol Testing

There is no local S3 service in this environment; the S3 protocol is tested against a real bucket.
See [`examples/19_s3`](../examples/19_s3/) for the setup.

## ODBC Testing

`odbc/run.sh` tests the `odbc://` connector on Linux against the SQL Server, PostgreSQL and MySQL containers above, and a SQLite file, each through its ODBC driver:

```bash
docker-compose up -d          # the databases
odbc/run.sh                   # build a Linux binary in Docker, then run the tests
odbc/run.sh --no-build        # reuse the last Linux build
```

It builds TinyETL from your working tree in a `rust` container (no system OpenSSL or unixODBC, like a release build) and runs it in a Debian image with Microsoft's ODBC Driver 18, psqlODBC, MariaDB Connector/ODBC and the SQLite ODBC driver (`odbc/Dockerfile`; installing Driver 18 accepts Microsoft's EULA). For each database it writes `odbc/typed.csv` (decimals, booleans, NULLs, Unicode, a 9,000-character value) to a new table, reads it back and compares the values and column order, then checks that a second run appends and that `--truncate` replaces the rows. The first build needs about 6 GB of Docker memory (`colima start --memory 8`).

## Troubleshooting

### Check if services are running
```bash
docker-compose ps
```

### Check service health
```bash
docker-compose exec postgres pg_isready -U testuser -d testdb
docker-compose exec mysql mysqladmin ping -h localhost -u testuser -ptestpass
docker-compose exec mongodb mongosh --eval "db.adminCommand('ping')"
```

### Reset everything
```bash
docker-compose down -v
docker-compose up -d
```