kumoai.connector.BigQueryConnector#
- class kumoai.connector.BigQueryConnector[source]#
Bases:
ConnectorEstablishes a connection to a BigQuery database.
Authentication requires passing a private key ID, private key string, client ID, client email, token URI, and authentication URI to the connector, either via environment variables (
BIGQUERY_PRIVATE_KEY_ID,BIGQUERY_PRIVATE_KEY,BIGQUERY_CLIENT_ID,BIGQUERY_CLIENT_EMAIL,BIGQUERY_TOKEN_URI,BIGQUERY_AUTH_URI), or via keys in the credentials dictionary (private_key_id,private_key,client_id,client_email,token_uri,auth_uri).import kumoai # Either pass `credentials=dict(private_key_id=..., private_key=..., # client_id=..., client_email=..., token_uri=..., auth_url=...)` or set # the aforementioned environment variables: connector = kumoai.BigQueryConnector( name="<connector_name>", project_id="<bigquery_project_id>", dataset_id="<bigquery_dataset_id>", 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.project_id (
str) – The project ID to connect to.dataset_id (
str) – The dataset ID within the connected project.credentials (
Optional[Dict[str,str]]) – The private key ID, private key, client ID, client email, token URI, and auth URI that correspond to this BigQuery account.
- classmethod get_by_name(name)[source]#
Returns an instance of a named BigQuery 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.SnowflakeConnector.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: