# API Test Data Sqlite Seeding

> Seeds database test data with SQL scripts and Node scripts: sqlite3 import, PostgreSQL COPY/INSERT, fixtures, and repeatable seed flows. Use when working with sqlite seeding, postgres seeding or when the user mentions sqlite seeding, postgres seeding.

- Skill: `opknock/api-test-data-sqlite-seeding` (Agent Skill)
- Install (CLI): `npx get-skill add opknock/api-test-data-sqlite-seeding`
- Raw SKILL.md: https://api.skillmd.com/api/skills/opknock/api-test-data-sqlite-seeding/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Data & Analytics
- License: MIT
- Author: OpKnock (https://skillmd.com/u/opknock)
- Updated: 2026-11-23
- Page: https://skillmd.com/skills/opknock/api-test-data-sqlite-seeding

---


Seeds database test data with SQL scripts and Node scripts: sqlite3 import, PostgreSQL COPY/INSERT, fixtures, and repeatable seed flows.

## Agentic Workflow: Read -> Reason -> Act (api-test-data-sqlite-seeding)

You are **Api Test Data Sqlite Seeding** (testing) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.

### 1. Read — testing context for `api-test-data-sqlite-seeding`
- Domain: Seeds database test data with SQL scripts and Node scripts: sqlite3 import, PostgreSQL COPY/INSERT, fixtures, and repeatable seed flows.
- **sqlite-seeding**: Seed SQLite databases for API tests — `sqlite3 test.db "CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TE`
- **postgres-seeding**: Seed PostgreSQL for integration tests — `psql -d app -f seed.sql`
- Check `knowledge` and `prerequisites: faker, node.js, python`

### 2. Reason — think for `api-test-data-sqlite-seeding`
- For `sqlite-seeding`: Seed SQLite databases for API tests — decide which checks to run
- For `postgres-seeding`: Seed PostgreSQL for integration tests — decide which checks to run
- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs

### 3. Act — execute with `api-test-data-sqlite-seeding` tools
- Tools: `Glob`, `Grep`, `Read`, `Sqlite3`, `Bash` (see frontmatter `tools`/`allowed-tools`)
- Use `safe_path` for any write; record evidence (paths, checksums)
- Fingerprint: `api-test-data-sqlite-seeding:406d3af5`

# API Test Data v2 - Database Seeding

Database seeding for API tests.

## What This Skill Does
- Seeds SQLite and PostgreSQL fixtures
- Resets state between tests
- Exports reusable seed scripts

## When to Use
- Integration test databases
- CI ephemeral environments
- Reproducible local dev data

## Real Commands

```bash
sqlite3 test.db "INSERT INTO users (name, email) VALUES ('alice', 'a@example.com')"
psql -d app -c "COPY users (name, email) FROM '/tmp/users.csv' WITH (FORMAT csv, HEADER true)"
psql -d app -c "TRUNCATE users RESTART IDENTITY"
```

## Seeding Strategy
1. Truncate with restart identity
2. Insert fixtures in dependency order
3. Re-verify with count queries

## Testing
- Reset then seed in test setup hooks
- Verify foreign keys after truncation
- Time large seeds with COPY vs INSERT


## Best Practices
- Keep seed scripts idempotent
- Version seeds with migrations
- Use CSV COPY for bulk rows

## Capabilities

### sqlite-seeding
Seed SQLite databases for API tests

**Parameters:**
- `db-file` (string): SQLite database file
- `table` (string): Target table
- `sql` (string): SQL statement

**Commands:**
- `sqlite3 test.db "CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)"`
- `sqlite3 test.db "INSERT INTO users (name, email) VALUES ('alice', 'a@localhost'), ('bob', 'b@localhost')"`
- `sqlite3 test.db "SELECT COUNT(*) FROM users"`
- `node -e "const db=require('better-sqlite3')('test.db'); db.prepare('INSERT INTO users (name,email) VALUES (?,?)').run('carol','c@example.com'); console.log(db.prepare('SELECT COUNT(*) c FROM users').get())"`
- `sqlite3 test.db ".dump" > seed.sql`

**Examples:**
- sqlite3 multi-row INSERT seeds fixtures
- better-sqlite3 runs prepared statements
- .dump exports the full seed

### postgres-seeding
Seed PostgreSQL for integration tests

**Commands:**
- `psql -d app -f seed.sql`
- `psql -d app -c "COPY users (name, email) FROM '/tmp/users.csv' WITH (FORMAT csv, HEADER true)"`
- `psql -d app -c "TRUNCATE users RESTART IDENTITY"`
- `pg_dump --data-only -t users app > seed.sql`

**Examples:**
- -cli --help
- -api --help

## References
- [SQLite CLI Docs](https://www.sqlite.org/cli.html)
- [PostgreSQL COPY](https://www.postgresql.org/docs/current/sql-copy.html)

