● Guides

From a Database

This walks the whole loop against a live database: connect, inspect, generate, validate, look at the output. Pick your database.

1. Connect and introspect

PostgreSQL

dbsprout init --db postgresql://user:pass@localhost:5432/mydb

MySQL

dbsprout init --db mysql+pymysql://user:pass@localhost:3306/mydb

SQLite

dbsprout init --db sqlite:///myapp.db

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

init writes dbsprout.toml:

[schema]
dialect = "postgresql"
source = "postgresql://user:***@localhost:5432/mydb"
snapshot = ".dbsprout/snapshots/a1b2c3d4.json"

[generation]
default_rows = 100
seed = 42
engine = "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 = true

3. Generate

dbsprout generate --rows 1000

Files are written to ./seeds/, numbered by insertion order so they apply cleanly:

seeds/
  001_authors.sql
  002_books.sql
  003_orders.sql

4. Validate

dbsprout validate

DBSprout checks FK satisfaction, PK uniqueness, UNIQUE and NOT NULL — all must be 100%.

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]").
  • doctor checks connectivity, drivers, Python version, disk, and scans dbsprout.toml for secrets.

Next