AWS Redshift connects with Python Part 1 — Setup a Redshift connection with Python.
Published: 2022-07-04 11:13:41


## AWS Redshift connects with Python Part 1 — Setup a Redshift connection with Python.

Welcome to the *Amazon Redshift Cluster Management Guide*. Amazon Redshift is a fully managed, petabyte-scale data warehouse service in the cloud. You can start with just a few hundred gigabytes of data and scale to a petabyte or more.

You can get more details on the websites: [https://docs.aws.amazon.com/redshift/latest/mgmt/welcome.html](https://docs.aws.amazon.com/redshift/latest/mgmt/welcome.html)

We are going to set up from the AWS side by step by step approach.

![](https://cdn-images-1.medium.com/max/2000/1*kAV5E6ENslE-8BvKxeQI9Q.png)

I hope you guys have created the AWS account, we logged in to the AWS Redshift account. The page looks like shown below here.

![](https://cdn-images-1.medium.com/max/2188/1*mhnjKIBPcqtIlG6UDnG4Ug.jpeg)

Above page which is the AWS Redshift page, on that page their is an option called “Create cluster”. We have to click on it and proceed to further.

![](https://cdn-images-1.medium.com/max/2000/1*5zbm3mtJlHjixU3BgECKYQ.jpeg)

After clicking on “Create Cluster” we need to give the name Cluster identifier, I have given “redshift-cluster-v1” and after that clicking on the Free trial option. The red colour box I have shown above is on the right-hand side.

After that, we scroll down to see that we have to give the Database name, port number and password. But I chose to keep the default as it is. But we have to give our password.

![](https://cdn-images-1.medium.com/max/2000/1*yPaZ4oVBySm-RYZMfHoV6Q.jpeg)

After entering the Admin user name and password, click on Create cluster.

After clicking “Create cluster” the page will automatically navigate to the cluster homepage and it will show the status of your cluster and it takes time.

![](https://cdn-images-1.medium.com/max/3014/1*Sad4NAtf5b9n3l44S3w6Rw.jpeg)

The above image shows the status of the cluster, and the status is “Modifying Creating”.

![](https://cdn-images-1.medium.com/max/2952/1*ymavhlE2_RWjvoQULBsVcw.jpeg)

After the cluster has been created, the status will show “Available”.

Now our cluster is created with some demo data inside the databases.

After that, we have to make changes in the VPC Security group to communicate between Python and redshift.

First, we must click our redshift cluster name, go down and click on the “Properties” tab.

![](https://cdn-images-1.medium.com/max/3084/1*oZrqCTk7DKp7Z-A189-tzQ.jpeg)

Inside the “Properties” tab we will see, “Network and Security settings”, click on the links which are present below “VPC security group” which is in the blue box mentioned in the below diagram.

![](https://cdn-images-1.medium.com/max/3038/1*asXqLR_DNSQtQDKIfg_esw.jpeg)

After clicking that blue link we will redirect to the Security Group page. And we have to search for “Inbound rules”

![](https://cdn-images-1.medium.com/max/2720/1*5O4RUSAHQIHaJzBbeXTdFg.jpeg)

And Inbound rules are present at bottom of the screen, the green box which I had shown in the above image.

After clicking the “Inbound rules” we will see the list of various inbound rules and we click on “Edit Inbound rules”. And we will change some of the properties.

![](https://cdn-images-1.medium.com/max/2616/1*lXnCFTEwp9KJfkW461Br2Q.jpeg)

After that click on the “Add rules”, which will prompt new data and we need to modify it.

![](https://cdn-images-1.medium.com/max/3028/1*NnL6pAF_Fu7i91H4ujbdDQ.jpeg)

![](https://cdn-images-1.medium.com/max/3020/1*0qLLVW7N4m1tHWAt3LJqRw.jpeg)

We need to modify the fields mentioned below Image and which are inside the green box.

![](https://cdn-images-1.medium.com/max/2000/1*U6nGjM-iDQf_wBOKFRkKXg.jpeg)

By setting the VPC security group, we will connect AWS Redshift to python.

Now, only one thing remaining is that we have to make our cluster publicly accessible. So, we come to cluster home and click on the check box of the cluster.

![](https://cdn-images-1.medium.com/max/2526/1*W9r6P8TFpU4XFUkms1KBBg.jpeg)

After done selecting your choice of the cluster, then go to Action, locate Modify publicly accessible setting. A prompt window will arise and we have to make it enable.

![](https://cdn-images-1.medium.com/max/2000/1*RkHDTKbX6p36lq2Oq10KYg.jpeg)

Click “Enable” and save changes. Now our Redshift is ready for python.

I will publish the code of python in the next article part 2.