Snowflake¶
Installation¶
Use extras snowflake to install all required packages.
$ pip install mara-db[snowflake]
The official snowsql client is required. See the Installing SnowSQL page for installation details.
Configuration examples¶
import mara_db.dbs
mara_db.config.databases = lambda: {
'dwh': mara_db.dbs.SnowflakeDB(
account='kaXXXXX.regio.cloud',
user='<user>',
password='<my_strong_password>',
database='dwh'),
}
import mara_db.dbs
mara_db.config.databases = lambda: {
'dwh': mara_db.dbs.BigQueryDB(
account='kaXXXXX.regio.cloud',
user='<user>',
private_key_file='<path>/rsa_key.p8',
private_key_passphrase='<passphrase>',
database='dwh'),
}
You can configure a named connection in the snowsql config file. See here.
import mara_db.dbs
mara_db.config.databases = lambda: {
'dwh': mara_db.dbs.BigQueryDB(
connection='my_example_connection',
database='dwh'),
}
API reference¶
This section contains database specific API in the module.
Configuration¶
- class mara_db.dbs.SnowflakeDB(connection: Optional[str] = None, account: Optional[str] = None, user: Optional[str] = None, password: Optional[str] = None, database: Optional[str] = None, private_key_file: Optional[str] = None, private_key_passphrase: Optional[str] = None)¶
A database connection to a Snowflake database
- __init__(connection: Optional[str] = None, account: Optional[str] = None, user: Optional[str] = None, password: Optional[str] = None, database: Optional[str] = None, private_key_file: Optional[str] = None, private_key_passphrase: Optional[str] = None) None ¶
Connection information for a Snowflake database
- Parameters
connection – The connection name definend in the snowsql configuration ~/.snowsql/config
account – The account identifier. See here: https://docs.snowflake.com/en/user-guide/admin-account-identifier.html
user – The user name
password – The password of the user
database – The database name
private_key_file – Path to private key file in PEM format used for key pair authentication. The private key file must be encrypted.
private_key_passphrase – The passphrase for the private key file.
- property sqlalchemy_url¶
Returns the SQLAlchemy url for a database