context introspect
The introspect command connects to a database, reads its schema, and generates .context.yaml files with Bronze-level metadata.
context introspect --db <connection-url>Options
Section titled “Options”| Option | Description | Default |
|---|---|---|
--db <url> | Database connection string | $DATABASE_URL |
--source <name> | Logical name for this data source | Inferred from DB name |
--tables <glob> | Filter tables by glob pattern | * (all tables) |
--model-name <name> | Override the model name in output files | Table name |
--select | Interactively pick which tables to include | Off (all tables) |
Examples
Section titled “Examples”Introspect all tables
Section titled “Introspect all tables”context introspect --db postgres://localhost:5432/myappIntrospect specific tables
Section titled “Introspect specific tables”context introspect \ --db postgres://localhost:5432/myapp \ --tables "users,orders,order_*"Interactive table selection
Section titled “Interactive table selection”context introspect \ --db postgres://localhost:5432/myapp \ --selectThis 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.
Name the source
Section titled “Name the source”context introspect \ --db postgres://localhost:5432/myapp \ --source productionThis produces files namespaced under context/production/.
Override model name
Section titled “Override model name”context introspect \ --db postgres://localhost:5432/myapp \ --tables "user_accounts" \ --model-name usersOutput
Section titled “Output”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: ordersSupported databases
Section titled “Supported databases”- DuckDB (
duckdb://path.duckdb) - PostgreSQL (
postgres://...) - MySQL (
mysql://...) - SQL Server (
mssql://...) - SQLite (
.sqlite,.sqlite3files) - 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.
Next steps
Section titled “Next steps”- Enrich the generated files with
context enrich - Validate them with
context lint