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

FlagDefaultDescription
--rows1000Number of rows to generate per table
--target""Target database DSN
--url""Alias for --target
--fastfalsePrioritize generation speed over distribution accuracy using an optimized sampling strategy
--sample-rows0Draw a fixed-size sample of source rows to balance generation speed and distribution accuracy
--no-samplingfalseSkip source data analysis and generate purely random values
--create-tablestrueCreate schemas and tables on the output before writing data
--yesfalseSkip interactive preview and use defaults (CI mode)
--input-format""Input format: ddl (requires --input or --stdin)
--input""Input file for paste mode
--stdinfalseRead input from stdin (requires --input-format)
--format"json"Data output format: json or csv (paste mode without --target)
--formulaComputed column formula (repeatable: --formula 'col=expr')
--datasetRegister a CSV dataset (repeatable: --dataset name=path.csv)
--mapMap a column to a dataset (repeatable: --map table.col=dataset.col)
--no-cachefalseBypass schema cache and force re-introspection

Persistent flags

These flags are inherited from the root command and available on generate:

FlagDefaultDescription
--api-key""API key for non-interactive authentication
--output"pretty"Output format: pretty, plain, or json

Environment variables

VariableDescription
WEAVORI_DATABASE_URLDefault DSN when no argument or --target is provided
WEAVORI_API_KEYAPI key for non-interactive auth (alternative to --api-key)
WEAVORI_OUTPUTOutput 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.