kumoai.connector.DatabricksConnector#
- class kumoai.connector.DatabricksConnector[source]#
Bases:
ConnectorEstablishes a connection to a Databricks database.
Authentication requires passing either a client ID and client secret, or a personal access token, to the connector, either via environment variables (
DATABRICKS_CLIENT_IDandDATABRICKS_CLIENT_SECRET, orDATABRICKS_TOKEN), or via keys in the credentials dictionary (client_idandclient_secret, ortoken).import kumoai # Either pass `credentials=dict(client_id=..., client_secret=..., # token=...) or set the 'DATABRICKS_CLIENT_ID' and # 'DATABRICKS_CLIENT_SECRET' (or 'DATABRICKS_TOKEN') environment # variables: connector = kumoai.connector.DatabricksConnector( name="<connector_name>", host="<databricks_host_name>", cluster_id="<databricks_cluster_id>", warehouse_id="<databricks_warehouse_id>", catalog="<databricks_catalog_name>", credentials=credentials, ) # List all tables: print(connector.table_names()) # Check whether a table is present: assert "articles" in connector # Fetch a source table (both approaches are equivalent): source_table = connector["articles"] source_table = connector.table("articles")
- Parameters:
name (
str) – The name of the connector.host (
str) – The host name.cluster_id (
str) – The cluster ID of this warehouse.warehouse_id (
str) – The warehouse ID of this warehous.catalog (
str) – The name of the Databricks catalog.credentials (
Optional[Dict[str,str]]) – The client ID, client secret, and personal access token that correspond to this Databricks account.
- __init__(name, host, cluster_id, warehouse_id, catalog, credentials=None, _bypass_creation=False)[source]#
- classmethod get_by_name(name)[source]#
Returns an instance of a named Databricks Connector, including those created in the Kumo UI.
- Parameters:
name (
str) – The name of the existing connector.- Return type:
Self
Example
>>> import kumoai >>> connector = kumoai.DatabricksConnector.get_by_name("name")
- property source_type: DataSourceType#
Returns the data source type accessible by this connector.
- table(name)#
Returns a
SourceTableobject corresponding to a source table behind this connector. A source table is a view into the raw data of tablename. To use a source table in Kumo, you will need to construct aTablefrom the source table.- Parameters:
name (
str) – The table name.- Raises:
ValueError – if
namedoes not exist in the backing connector.- Return type: