weavori generate
Connect to a PostgreSQL database and generate a referentially intact synthetic replica.
Usage
weavori generate [dsn] [flags]
The generate command introspects your source database, resolves foreign key dependencies, samples column distributions, and generates synthetic data into a target database.
Two modes are available:
- Standard mode — connects to a live source database, introspects its schema
- Paste mode (
--input-format ddl) — parses CREATE TABLE statements without a live database
Flags
| Flag | Default | Description |
|---|---|---|
--rows | 1000 | Number of rows to generate per table |
--target | "" | Target database DSN |
--url | "" | Alias for --target |
--fast | false | Prioritize generation speed over distribution accuracy using an optimized sampling strategy |
--sample-rows | 0 | Draw a fixed-size sample of source rows to balance generation speed and distribution accuracy |
--no-sampling | false | Skip source data analysis and generate purely random values |
--create-tables | true | Create schemas and tables on the output before writing data |
--yes | false | Skip interactive preview and use defaults (CI mode) |
--input-format | "" | Input format: ddl (requires --input or --stdin) |
--input | "" | Input file for paste mode |
--stdin | false | Read input from stdin (requires --input-format) |
--format | "json" | Data output format: json or csv (paste mode without --target) |
--formula | Computed column formula (repeatable: --formula 'col=expr') | |
--dataset | Register a CSV dataset (repeatable: --dataset name=path.csv) | |
--map | Map a column to a dataset (repeatable: --map table.col=dataset.col) | |
--no-cache | false | Bypass schema cache and force re-introspection |
Persistent flags
These flags are inherited from the root command and available on generate:
| Flag | Default | Description |
|---|---|---|
--api-key | "" | API key for non-interactive authentication |
--output | "pretty" | Output format: pretty, plain, or json |
Environment variables
| Variable | Description |
|---|---|
WEAVORI_DATABASE_URL | Default DSN when no argument or --target is provided |
WEAVORI_API_KEY | API key for non-interactive auth (alternative to --api-key) |
WEAVORI_OUTPUT | Output format (alternative to --output): pretty, plain, or json |
Examples
Plan only (no output)
weavori generate "postgres://user:pass@localhost:5432/source"
Connecting to source database...
Introspecting schema...
Connected successfully.
Found 2 schema(s).
"public": 5 table(s)
- users (6 cols, 0 FK(s))
...
Generation order (parents before children):
1. public.users
2. public.products
3. public.orders
...
✓ Schema introspection and FK resolution complete.
Specify --target <dsn> to generate and export synthetic data.
Full generation
weavori generate "postgres://user:pass@localhost:5432/source" \
--target "postgres://user:pass@localhost:5432/target" \
--rows 10000
Fast mode (1% sampling)
weavori generate "postgres://user:pass@localhost:5432/source" \
--target "postgres://user:pass@localhost:5432/target" \
--fast --rows 50000
CI mode (non-interactive)
weavori generate "postgres://user:pass@localhost:5432/source" \
--target "postgres://user:pass@localhost:5432/target" \
--rows 50000 --yes --output plain
Bypass schema cache
weavori generate "postgres://user:pass@localhost:5432/source" \
--target "postgres://user:pass@localhost:5432/target" \
--no-cache
DDL paste mode
Generate synthetic data from DDL definitions without a live source database:
weavori generate --input schema.sql --input-format ddl --rows 100
Or pipe DDL from stdin:
cat schema.sql | weavori generate --stdin --input-format ddl --format csv
Output goes to stdout as JSON (default) or CSV (use --format csv). Specify --target to write to a database instead.
Formulas
Define computed columns using repeatable --formula flags:
weavori generate "postgres://user:pass@localhost:5432/source" \
--target "postgres://user:pass@localhost:5432/target" \
--formula 'full_name=concat(first_name, " ", last_name)'
Custom datasets
Use CSV files as lookup sources for column generation:
weavori generate "postgres://user:pass@localhost:5432/source" \
--target "postgres://user:pass@localhost:5432/target" \
--dataset customers=customers.csv \
--map orders.customer_id=customers.id
Trigger detection
Weavori automatically detects ON INSERT triggers during introspection and accounts for them in the generation plan. Columns populated by triggers are skipped during generation, and the generation order respects trigger dependencies.