Seed a real database
seed_databaseGenerate realistic, schema-based test data for Postgres or SQLite using only a connection string. It reads the live schema, plans before writing, seeds respecting foreign keys, and verifies integrity.
Instructions
Fill a live Postgres or SQLite database with realistic, connected data, read from the database's own schema.
Reads the tables, columns, and foreign keys directly from the target database, generates data that respects them, inserts parents before children, then queries the database back to confirm every foreign key resolves. No schema file and no ORM are needed: a connection string is enough.
SAFETY — this is the only Misata tool that writes to a user's database:
It plans by default. With
apply=False(the default) nothing is written; you get the table list, insert order, existing row counts, and what would be inserted. Show that plan to the user.Only call again with
apply=Trueafter the user has seen the plan and agreed. Never passapply=Trueon a first call.If any target table already has rows, the write is refused unless the user chooses
truncate=True(wipe and reseed) orappend=True(keep existing rows, seed only empty tables, and draw foreign keys from the rows already there). Never guess between these.truncate=TrueDESTROYS existing data. Only use it on a throwaway development database and only when the user explicitly asks.
Args:
db_url: Connection string, e.g. postgresql://localhost/myapp_dev
or sqlite:///dev.db.
rows: Base row count; reference and transaction tables scale from it.
apply: False (default) plans only. True performs the write.
truncate: Wipe target tables (children first) before seeding.
append: Keep populated tables and seed only the empty ones.
tables: Optional allow-list of table names to seed.
skip_tables: Tables to leave untouched (migrations, auth, etc.).
seed: Random seed; the same seed reproduces the same data.
Returns:
A plan (applied: false) or a result with per-table row counts and
a per-relationship integrity proof (integrity.verified).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rows | No | ||
| seed | No | ||
| apply | No | ||
| append | No | ||
| db_url | Yes | ||
| tables | No | ||
| truncate | No | ||
| skip_tables | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |