From a Database
This walks the whole loop against a live database: connect, inspect, generate, validate, look at the output. Pick your database.
import { Tabs, TabItem } from ‘@astrojs/starlight/components’;
1. Connect and introspect
Section titled “1. Connect and introspect”The connection URL can also come from the DBSPROUT_TARGET_DB environment
variable. init reads tables, columns, primary keys, foreign keys, indexes
and constraints via SQLAlchemy.
2. Inspect the generated config
Section titled “2. Inspect the generated config”init writes dbsprout.toml:
[schema]dialect = "postgresql"source = "postgresql://user:***@localhost:5432/mydb"snapshot = ".dbsprout/snapshots/a1b2c3d4.json"
[generation]default_rows = 100seed = 42engine = "heuristic"output_format = "sql"output_dir = "./seeds"
[privacy]tier = "local"Edit per-table row counts before generating:
[tables.users]rows = 50
[tables.audit_logs]exclude = true3. Generate
Section titled “3. Generate”dbsprout generate --rows 1000Files are written to ./seeds/, numbered by insertion order so they apply
cleanly:
seeds/ 001_authors.sql 002_books.sql 003_orders.sql4. Validate
Section titled “4. Validate”dbsprout validateDBSprout checks FK satisfaction, PK uniqueness, UNIQUE and NOT NULL — all must be 100%.
Connection won’t work?
Section titled “Connection won’t work?”dbsprout doctor --db postgresql://user:pass@localhost:5432/mydb- Install database drivers with the
[db]extra:pip install "dbsprout[db]"(SQL Server:pip install "dbsprout[mssql]"). doctorchecks connectivity, drivers, Python version, disk, and scansdbsprout.tomlfor secrets.
- Output Formats — CSV, JSON, Parquet, direct insert
- Recipes — solve a specific problem