Redshift Cluster
Another integration that DataCamp Workspace supports is a connection to Amazon Redshift clusters. Using environment variables, you can connect your own workspace to data stored in a Redshift cluster. Make sure to understand how to set up and connect integrations securely to you workspace, as explained in this article.
Once you are familiar with the concept of environment variables, you can insert your Redshift credentials as follows. Pay attention to the names chosen for the environment variables. These should be consistent with the ones you use in your workspace itself.
The value of these environment variables will now get securely saved. You can use them in you workspace and connect to your cluster. Check out following code sample to set up a connection using the pre-installed redshift_connector SDK.
1
import redshift_connector
2
3
conn = redshift_connector.connect(
4
host=os.environ["REDSHIFT_HOST"],
5
database=os.environ["REDSHIFT_DB_NAME"],
6
user=os.environ["REDSHIFT_USER"],
7
password=os.environ["REDSHIFT_PASSWORD"]
8
)
Copied!

Sample database: online ticket sales

We also provide you with a sample database about online ticket sales for events such as sporting events, shows, and concerts (source). If you want to connect to the Amazon Redshift cluster that hosts these files, there are only two things you will need to do.
First open a new workspace using this template in Python.
Next, connect following set of credentials to your workspace. These will give you read access to the sample database.
  • REDSHIFT_DB_NAME = online_ticket_sales
  • REDSHIFT_HOST = workspace-redshift-cluster-demo-prod.ceh21gkfoxgb.us-east-1.redshift.amazonaws.com
  • REDSHIFT_PASSWORD = Workspace1
  • REDSHIFT_USER = workspace
Last modified 1mo ago