db.utils

emtellipro.db.utils

Some helper utilities for working with databases.

Module Contents

Functions

NameDescription
snowflake_connectConnect to Snowflake and return an SQLAlchemy engine. This handles private key parsing and usage.

API

emtellipro.db.utils.snowflake_connect

emtellipro.db.utils.snowflake_connect(
url,
private_key_path = None,
private_key_passphrase = None,
**create_kwargs
) -> sqlalchemy.Engine

Connect to Snowflake and return an SQLAlchemy engine. This handles private key parsing and usage.

For the specifics on which parameters are supported see the Snowflake documentation.

Parameters:

url

The connection URL; this is sent directly to create_engine. The format is described in the Snowflake documentation.

private_key_path

The path to the private key, if used.

private_key_passphrase

If using a private key, this is the passphrase to decrypt it. This parameter is optional, and if it’s not set, the passphrase will be read from either the SNOWFLAKE_PRIVATE_KEY_PASSPHRASE or SNOWSQL_PRIVATE_KEY_PASSPHRASE environment variables.

**create_kwargs

These are passed to create_engine if private key path is not set.

Returns:

The SQLAlchemy engine that can be used to connect to Snowflake.

Return type: Engine