Connecting to Redshift in a Python recipe

Level 4
Connecting to Redshift in a Python recipe

I want to create Python plugins/recipes that connect to Redshift. Is there any way to do this? I've seen posts about HDFS, Spark, etc. but no documentation or sample code for Python > Redshift. 

0 Kudos
1 Reply


Are you looking to actually connect to Redshift from within your Python code itself? If not, and you are simply trying to use existing Redshift tables in your plugin or recipe, then you can simply create a dataset in DSS pointing to the table(s) and use our existing dataset APIs, similar to the examples that can be found in our documentation here:

Otherwise, if you are looking to connect directly via Python, then it's important to keep in mind that "Python in DSS" is essentially the same as "Python outside of DSS". Therefore, this would be similar to asking how you can generically connect to Redshift through Python locally. From doing a quick Google search online, it appears that one common approach is to leverage the psycopg2 package in Python (which you would need to first install in a code environment). Then, you could write additional code to establish the connection itself and either pull the data in, submit queries, write data, etc.

If you do decide to go this route, you may find the following links helpful as well: