How to Connect to Alli Data's Redshift Cluster
Alli Marketplace makes several environment variables avilable to help with database connections:
ALLI_DATA_REDSHIFT_URL
ALLI_DATA_REDSHIFT_HOST
ALLI_DATA_REDSHIFT_PORT
ALLI_DATA_REDSHIFT_USER
ALLI_DATA_REDSHIFT_PASSWORD
ALLI_DATA_REDSHIFT_DATABASE
All of these environment variables are scope to the Alli Marketplace environment (production or staging) and to the client on whose behalf the pallet execution is running. For example, you may not access client data for acme
when a pallet is running for wayne_enterprises
.
ALLI_DATA_REDSHIFT_URL
is the easiest way to connect if your database library supports it:
import os
from sqlalchemy import create_engine
db_engine = create_engine(os.environ['ALLI_DATA_REDSHIFT_URL'])
Otherwise invidual environment variables may be used. For example, with DBT:
company-name:
target: allidata
outputs:
allidata:
type: redshift
host: "{{ env_var('ALLI_DATA_REDSHIFT_HOST') }"
user: "{{ env_var('ALLI_DATA_REDSHIFT_USER') }"
pass: "{{ env_var('ALLI_DATA_REDSHIFT_PASSWORD') }"
port: "{{ env_var('ALLI_DATA_REDSHIFT_PORT') }"
dbname: "{{ env_var('ALLI_DATA_REDSHIFT_DATABASE') }"
# ...