For the complete documentation index, see llms.txt. This page is also available as Markdown.

Sources from Connectors

From a warehouse table to a causal model without leaving Python: register a connector, author custom SQL against the live database, import the result as a source, and model it. Outputs shown are real transcripts against a PostgreSQL database; Snowflake, MySQL, ClickHouse, MongoDB, S3, and the other connector types follow the same verbs — swap the type and credentials.

Register and test

Credentials are stored encrypted server-side and are never returned by the API — connector reads redact them.

>>> ws = rc.workspace("connector-demo", create=True)
>>> connector = ws.add_connector(
...     "demo-warehouse", "PostgreSQL",
...     host="db.internal", port=5432,
...     database="warehouse", username="demo", password=os.environ["DB_PASSWORD"],
... )
>>> connector.test()
{'isConnected': True}

Browse the schema

The same hierarchy the UI shows — for SQL connectors: schemas, then tables, then columns (Snowflake adds warehouses and databases above them):

>>> connector.browse("tables", schema="public")
{'options': [{'value': 'store_weeks',
   'label': 'store_weeks',
   'type': None,
   'metadata': {'columnCount': '6'}}],
 'hierarchy': ['schemas', 'tables', 'columns'],
 'currentLevel': 'tables',
 'nextLevel': 'columns'}

Author custom SQL against the live database

query() runs your SQL with a row cap and returns sample rows as a DataFrame. Nothing is stored, and database errors come back verbatim, so the authoring loop stays tight:

Import the query result as a source

The same SQL, minus the safety net: import_query() materialises the full result set as a source in the workspace and blocks until ingest completes. import_table("store_weeks") is the no-SQL shorthand for a whole table.

Straight to a causal model

A source-backed twin, discovery + training in one pass, and a question:

intervene is one of eight verbs a trained twin answers: predict for a specific case, explain for why, optimise for what to change, root_cause and anomalies for diagnosis. Asking a trained twin a question covers them all.

The loop from here is the same as any other source: re-import or sync on a schedule, twin.update() to fold new rows in (Working with Digital Twins), and Temporal and Panel Twins for time series and per-environment modelling.

Over REST, the same loop is POST /connectors → POST /connectors/{id}/preview-query → POST /connectors/{id}/import — see the REST API Reference.

Run it yourself

Download the connectors notebook

Last updated