blob: d00dedef932b203e062dea0c97adc4346dcd200f [file] [log] [blame]
"use strict";(self.webpackChunkdocs_v_2=self.webpackChunkdocs_v_2||[]).push([[8835],{21635:(e,t,r)=>{r.r(t),r.d(t,{assets:()=>l,contentTitle:()=>i,default:()=>u,frontMatter:()=>n,metadata:()=>o,toc:()=>d});var s=r(83117),a=(r(67294),r(3905));const n={title:"Amazon Redshift",hide_title:!0,sidebar_position:5,version:1},i=void 0,o={unversionedId:"databases/redshift",id:"databases/redshift",title:"Amazon Redshift",description:"AWS Redshift",source:"@site/docs/databases/redshift.mdx",sourceDirName:"databases",slug:"/databases/redshift",permalink:"/docs/databases/redshift",draft:!1,editUrl:"https://github.com/apache/superset/tree/master/docs/docs/databases/redshift.mdx",tags:[],version:"current",sidebarPosition:5,frontMatter:{title:"Amazon Redshift",hide_title:!0,sidebar_position:5,version:1},sidebar:"tutorialSidebar",previous:{title:"Apache Doris",permalink:"/docs/databases/doris"},next:{title:"StarRocks",permalink:"/docs/databases/starrocks"}},l={},d=[{value:"AWS Redshift",id:"aws-redshift",level:2},{value:"psycopg2",id:"psycopg2",level:3},{value:"redshift_connector",id:"redshift_connector",level:3},{value:"Using IAM-based credentials with Redshift cluster:",id:"using-iam-based-credentials-with-redshift-cluster",level:4},{value:"Using IAM-based credentials with Redshift serverless:",id:"using-iam-based-credentials-with-redshift-serverless",level:4}],p={toc:d},c="wrapper";function u(e){let{components:t,...r}=e;return(0,a.kt)(c,(0,s.Z)({},p,r,{components:t,mdxType:"MDXLayout"}),(0,a.kt)("h2",{id:"aws-redshift"},"AWS Redshift"),(0,a.kt)("p",null,"The ",(0,a.kt)("a",{parentName:"p",href:"https://pypi.org/project/sqlalchemy-redshift/"},"sqlalchemy-redshift")," library is the recommended\nway to connect to Redshift through SQLAlchemy."),(0,a.kt)("p",null,"This dialect requires either ",(0,a.kt)("a",{parentName:"p",href:"https://pypi.org/project/redshift-connector/"},"redshift_connector")," or ",(0,a.kt)("a",{parentName:"p",href:"https://pypi.org/project/psycopg2/"},"psycopg2")," to work properly."),(0,a.kt)("p",null,"You'll need to set the following values to form the connection string:"),(0,a.kt)("ul",null,(0,a.kt)("li",{parentName:"ul"},(0,a.kt)("strong",{parentName:"li"},"User Name"),": userName"),(0,a.kt)("li",{parentName:"ul"},(0,a.kt)("strong",{parentName:"li"},"Password"),": DBPassword"),(0,a.kt)("li",{parentName:"ul"},(0,a.kt)("strong",{parentName:"li"},"Database Host"),": AWS Endpoint"),(0,a.kt)("li",{parentName:"ul"},(0,a.kt)("strong",{parentName:"li"},"Database Name"),": Database Name"),(0,a.kt)("li",{parentName:"ul"},(0,a.kt)("strong",{parentName:"li"},"Port"),": default 5439")),(0,a.kt)("h3",{id:"psycopg2"},"psycopg2"),(0,a.kt)("p",null,"Here's what the SQLALCHEMY URI looks like:"),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre"},"redshift+psycopg2://<userName>:<DBPassword>@<AWS End Point>:5439/<Database Name>\n")),(0,a.kt)("h3",{id:"redshift_connector"},"redshift_connector"),(0,a.kt)("p",null,"Here's what the SQLALCHEMY URI looks like:"),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre"},"redshift+redshift_connector://<userName>:<DBPassword>@<AWS End Point>:5439/<Database Name>\n")),(0,a.kt)("h4",{id:"using-iam-based-credentials-with-redshift-cluster"},"Using IAM-based credentials with Redshift cluster:"),(0,a.kt)("p",null,(0,a.kt)("a",{parentName:"p",href:"https://docs.aws.amazon.com/redshift/latest/mgmt/working-with-clusters.html"},"Amazon redshift cluster")," also supports generating temporary IAM-based database user credentials."),(0,a.kt)("p",null,"Your superset app's ",(0,a.kt)("a",{parentName:"p",href:"https://docs.aws.amazon.com/redshift/latest/mgmt/generating-iam-credentials-role-permissions.html"},"IAM role should have permissions")," to call the ",(0,a.kt)("inlineCode",{parentName:"p"},"redshift:GetClusterCredentials")," operation."),(0,a.kt)("p",null,"You have to define the following arguments in Superset's redshift database connection UI under ADVANCED --\x3e Others --\x3e ENGINE PARAMETERS."),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre"},'{"connect_args":{"iam":true,"database":"<database>","cluster_identifier":"<cluster_identifier>","db_user":"<db_user>"}}\n')),(0,a.kt)("p",null,"and SQLALCHEMY URI should be set to ",(0,a.kt)("inlineCode",{parentName:"p"},"redshift+redshift_connector://")),(0,a.kt)("h4",{id:"using-iam-based-credentials-with-redshift-serverless"},"Using IAM-based credentials with Redshift serverless:"),(0,a.kt)("p",null,(0,a.kt)("a",{parentName:"p",href:"https://docs.aws.amazon.com/redshift/latest/mgmt/serverless-whatis.html"},"Redshift serverless")," supports connection using IAM roles."),(0,a.kt)("p",null,"Your superset app's IAM role should have ",(0,a.kt)("inlineCode",{parentName:"p"},"redshift-serverless:GetCredentials")," and ",(0,a.kt)("inlineCode",{parentName:"p"},"redshift-serverless:GetWorkgroup")," permissions on Redshift serverless workgroup."),(0,a.kt)("p",null,"You have to define the following arguments in Superset's redshift database connection UI under ADVANCED --\x3e Others --\x3e ENGINE PARAMETERS."),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre"},'{"connect_args":{"iam":true,"is_serverless":true,"serverless_acct_id":"<aws account number>","serverless_work_group":"<redshift work group>","database":"<database>","user":"IAMR:<superset iam role name>"}}\n')))}u.isMDXComponent=!0},3905:(e,t,r)=>{r.d(t,{Zo:()=>p,kt:()=>m});var s=r(67294);function a(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,s)}return r}function i(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach((function(t){a(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function o(e,t){if(null==e)return{};var r,s,a=function(e,t){if(null==e)return{};var r,s,a={},n=Object.keys(e);for(s=0;s<n.length;s++)r=n[s],t.indexOf(r)>=0||(a[r]=e[r]);return a}(e,t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(s=0;s<n.length;s++)r=n[s],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}var l=s.createContext({}),d=function(e){var t=s.useContext(l),r=t;return e&&(r="function"==typeof e?e(t):i(i({},t),e)),r},p=function(e){var t=d(e.components);return s.createElement(l.Provider,{value:t},e.children)},c="mdxType",u={inlineCode:"code",wrapper:function(e){var t=e.children;return s.createElement(s.Fragment,{},t)}},h=s.forwardRef((function(e,t){var r=e.components,a=e.mdxType,n=e.originalType,l=e.parentName,p=o(e,["components","mdxType","originalType","parentName"]),c=d(r),h=a,m=c["".concat(l,".").concat(h)]||c[h]||u[h]||n;return r?s.createElement(m,i(i({ref:t},p),{},{components:r})):s.createElement(m,i({ref:t},p))}));function m(e,t){var r=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var n=r.length,i=new Array(n);i[0]=h;var o={};for(var l in t)hasOwnProperty.call(t,l)&&(o[l]=t[l]);o.originalType=e,o[c]="string"==typeof e?e:a,i[1]=o;for(var d=2;d<n;d++)i[d]=r[d];return s.createElement.apply(null,i)}return s.createElement.apply(null,r)}h.displayName="MDXCreateElement"}}]);