Init PRO#
The init command connects to an existing database, inspects its schema, and prints a complete config to stdout. The output includes globals, up, seed, deseed, and down sections ready to use with the other commands.
Flags#
| Flag | Required | Description |
|---|---|---|
--schema | --database) | Schema or database name to introspect (e.g. public, defaultdb, dbo, SYSTEM) |
--database | --schema) | Alias for --schema |
--driver | Yes | Database driver (pgx, mysql, mssql, oracle, dsql, spanner, sqlite) |
--url | Yes | Connection URL for the source database |
mongodb, cassandra, and redis have no relational catalog to introspect, so init rejects them with init does not support driver "redis", use scaffold instead. Use scaffold for those, which builds a config from a table and column description rather than a live database.
edg init \
--driver pgx \
--url "postgres://root@localhost:26257/defaultdb?sslmode=disable" \
--schema public > workload.edgGenerated Config#
The generated config includes:
upCREATE TABLEstatements derived from the database’s own DDL (CockroachDB’sSHOW CREATE TABLE, MySQL’sSHOW CREATE TABLE, Oracle’sDBMS_METADATA.GET_DDL, reconstructed fromsyscatalog views for MSSQL, or reconstructed fromINFORMATION_SCHEMAfor Spanner, or read straight out ofsqlite_masterfor SQLite).seedOneINSERTper table with an expression for each non-generated column. Columns with auto-increment, identity, or default functions likegen_random_uuid()andnow()are skipped. Expressions are chosen by data type (e.g.uuid_v4()for UUID,uniform.int(1, 1000)for INT,gen('sentence:3')for VARCHAR).CHECK BETWEENconstraints are detected and used to narrow the range.deseedTRUNCATE(pgx, oracle) orDELETE FROM(mysql, mssql, spanner, sqlite) in reverse dependency order.downDROP TABLEin reverse dependency order.- Tables are topologically sorted so parent tables are created before children.
The output is a starting point. You’ll typically want to refine the seed expressions to produce more realistic data, add a
runsection, and adjustglobals.rows.
Examples by driver#
CockroachDB / PostgreSQL (pgx)
edg init \
--driver pgx \
--url "postgres://root@localhost:26257/dbname?sslmode=disable" \
--schema public > workload.edgAurora DSQL
edg init \
--driver dsql \
--url "clusterid.dsql.us-east-1.on.aws" \
--schema public > workload.edgMySQL
edg init \
--driver mysql \
--url "root:password@tcp(localhost:3306)/dbname?parseTime=true" \
--database dbname > workload.edgMSSQL
edg init \
--driver mssql \
--url "sqlserver://sa:P4ssw0rd@localhost:1433?database=master&encrypt=disable" \
--schema dbo > workload.edgOracle
edg init \
--driver oracle \
--url "oracle://system:password@localhost:1521/dbname" \
--schema SYSTEM > workload.edgSQLite
The database name is the attached schema, which is main unless you’ve ATTACHed others.
edg init \
--driver sqlite \
--url "file:edg.db" \
--database main > workload.edgGoogle Cloud Spanner (GoogleSQL)
edg init \
--driver spanner \
--url "projects/my-project/instances/my-instance/databases/my-db" \
--license "$EDG_LICENSE" \
--schema "" > workload.edg