Databricks¶
Installation¶
Use extras databricks to install all required packages.
$ pip install mara-db[databricks]
The official dbsqlcli client is required. See the Install the Databricks SQL CLI page for installation details.
Configuration examples¶
import mara_db.dbs
mara_db.config.databases = lambda: {
'dwh': mara_db.dbs.DatabricksDB(
host='dbc-a1b2345c-d6e78.cloud.databricks.com',
http_path='/sql/1.0/warehouses/1abc2d3456e7f890a',
access_token='dapi1234567890b2cd34ef5a67bc8de90fa12b'),
}
import mara_db.dbs
mara_db.config.databases = lambda: {
'dwh': mara_db.dbs.DatabricksDB(),
}
You need to define the environment variables DBSQLCLI_HOST_NAME, DBSQLCLI_HTTP_PATH and DBSQLCLI_ACCESS_TOKEN. See as well Environment variables
import mara_db.dbs
mara_db.config.databases = lambda: {
'dwh': mara_db.dbs.DatabricksDB(),
}
You need to define the database connection in the dbsqlclirc settings file. See as well Settings file. Note that using a custom settings file is currently not supported in Mara.
API reference¶
This section contains database specific API in the module.
Configuration¶
- class mara_db.dbs.DatabricksDB(host: Optional[str] = None, http_path: Optional[str] = None, access_token: Optional[str] = None)¶
A database connection to a Databricks
- __init__(host: Optional[str] = None, http_path: Optional[str] = None, access_token: Optional[str] = None) None ¶
Connection information for a Databricks
- Parameters
host – The hostname
http_path – The http path
access_token – The Access Token
- property sqlalchemy_url¶
Returns the SQLAlchemy url for a database