Skip to content

context introspect

The introspect command connects to a database, reads its schema, and generates .context.yaml files with Bronze-level metadata.

Terminal window
context introspect --db <connection-url>
OptionDescriptionDefault
--db <url>Database connection string$DATABASE_URL
--source <name>Logical name for this data sourceInferred from DB name
--tables <glob>Filter tables by glob pattern* (all tables)
--model-name <name>Override the model name in output filesTable name
--selectInteractively pick which tables to includeOff (all tables)
Terminal window
context introspect --db postgres://localhost:5432/myapp
Terminal window
context introspect \
--db postgres://localhost:5432/myapp \
--tables "users,orders,order_*"
Terminal window
context introspect \
--db postgres://localhost:5432/myapp \
--select

This presents a checklist of all tables in the database, letting you pick which ones to include. Useful for large databases where you only need a subset of tables.

Terminal window
context introspect \
--db postgres://localhost:5432/myapp \
--source production

This produces files namespaced under context/production/.

Terminal window
context introspect \
--db postgres://localhost:5432/myapp \
--tables "user_accounts" \
--model-name users

For each table, introspect creates a .context.yaml file containing:

  • Table name and schema
  • Column names, types, and nullability
  • Primary keys and unique constraints
  • Foreign key relationships
  • Indexes
# context/public/users.context.yaml (generated)
model:
name: users
source: myapp
schema: public
columns:
- name: id
type: integer
primary_key: true
nullable: false
- name: email
type: varchar(255)
nullable: false
unique: true
- name: created_at
type: timestamp
nullable: false
relationships:
- name: orders
type: has_many
foreign_key: user_id
references: orders
  • DuckDB (duckdb://path.duckdb)
  • PostgreSQL (postgres://...)
  • MySQL (mysql://...)
  • SQL Server (mssql://...)
  • SQLite (.sqlite, .sqlite3 files)
  • Snowflake (snowflake://account/database/schema)
  • BigQuery (bigquery://project/dataset)
  • ClickHouse (clickhouse://host:port)
  • Databricks (config file only)

Each adapter requires its own driver as an optional peer dependency. See Database Support for installation details.

Smart driver detection: If the required driver is not installed, context introspect (and context setup) will detect this and offer to install it automatically.