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#

FlagRequiredDescription
--schemaYes (or --database)Schema or database name to introspect (e.g. public, defaultdb, dbo, SYSTEM)
--databaseYes (or --schema)Alias for --schema
--driverYesDatabase driver (pgx, mysql, mssql, oracle, dsql, spanner, sqlite)
--urlYesConnection 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.edg

Generated Config#

The generated config includes:

  • up CREATE TABLE statements derived from the database’s own DDL (CockroachDB’s SHOW CREATE TABLE, MySQL’s SHOW CREATE TABLE, Oracle’s DBMS_METADATA.GET_DDL, reconstructed from sys catalog views for MSSQL, or reconstructed from INFORMATION_SCHEMA for Spanner, or read straight out of sqlite_master for SQLite).
  • seed One INSERT per table with an expression for each non-generated column. Columns with auto-increment, identity, or default functions like gen_random_uuid() and now() 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 BETWEEN constraints are detected and used to narrow the range.
  • deseed TRUNCATE (pgx, oracle) or DELETE FROM (mysql, mssql, spanner, sqlite) in reverse dependency order.
  • down DROP TABLE in 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 run section, and adjust globals.rows.

Examples by driver#

CockroachDB / PostgreSQL (pgx)

edg init \
--driver pgx \
--url "postgres://root@localhost:26257/dbname?sslmode=disable" \
--schema public > workload.edg

Aurora DSQL

edg init \
--driver dsql \
--url "clusterid.dsql.us-east-1.on.aws" \
--schema public > workload.edg

MySQL

edg init \
--driver mysql \
--url "root:password@tcp(localhost:3306)/dbname?parseTime=true" \
--database dbname > workload.edg

MSSQL

edg init \
--driver mssql \
--url "sqlserver://sa:P4ssw0rd@localhost:1433?database=master&encrypt=disable" \
--schema dbo > workload.edg

Oracle

edg init \
--driver oracle \
--url "oracle://system:password@localhost:1521/dbname" \
--schema SYSTEM > workload.edg

SQLite

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.edg

Google Cloud Spanner (GoogleSQL)

edg init \
--driver spanner \
--url "projects/my-project/instances/my-instance/databases/my-db" \
--license "$EDG_LICENSE" \
--schema "" > workload.edg