- Notifications
You must be signed in to change notification settings - Fork83
Query Redshift Serverless#114
-
Hello world, i am trying to make a connection to serverless redshift from a lambda with the following code. importredshift_connectorconn=redshift_connector.connect(iam=True,database="good_database",host="1234567890.us-west-2.redshift-serverless.amazonaws.com",region='us-west-2')deflambda_handler(event,context):withconn.cursor()ascursor:cursor.execute("SELECT * FROM public.usertable;")result=cursor.fetchall()print(result) but its returning me the following error [ERROR] ProgrammingError: This feature is not yet available i tried to look into this filehttps://github.com/aws/amazon-redshift-python-driver/blob/9ef850f5a97d55a2a2d523b6428bb8966576c9ec/redshift_connector/iam_helper.py#L24 thank you , |
BetaWas this translation helpful?Give feedback.
All reactions
Replies: 5 comments 4 replies
-
Hey raj, we anticipate releasing a new version of redshift-connector with support for IAM authentication with serverless shortly :) I'll provide an update here once available. |
BetaWas this translation helpful?Give feedback.
All reactions
-
@Brooke-white thank you |
BetaWas this translation helpful?Give feedback.
All reactions
-
@pruthvirajksuresh we've just released v2.0.908 which includes Redshift serverless support. Please use this version, or later, in order to use Redshift serverless with IAM authentication. Thank you for your patience! |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
@Brooke-white thank you for the update , but i am still facing the same issue . any suggestion would be helpfull below is the python code importredshift_connectorconn=redshift_connector.connect(iam=True,database="dev",host="12345678901.us-west-2.redshift-serverless.amazonaws.com",region='us-west-2')deflambda_handler(event,context):withconn.cursor()ascursor:cursor.execute("SELECT * FROM public.usertable;")result=cursor.fetchall()print(result) the error {"errorMessage":"Parameter validation failed:\nMissing required parameter in input:\"workgroupName\"","errorType":"ParamValidationError","requestId":"","stackTrace": [" File\"/var/lang/lib/python3.9/importlib/__init__.py\", line 127, in import_module\n return _bootstrap._gcd_import(name[level:], package, level)\n"," File\"<frozen importlib._bootstrap>\", line 1030, in _gcd_import\n"," File\"<frozen importlib._bootstrap>\", line 1007, in _find_and_load\n"," File\"<frozen importlib._bootstrap>\", line 986, in _find_and_load_unlocked\n"," File\"<frozen importlib._bootstrap>\", line 680, in _load_unlocked\n"," File\"<frozen importlib._bootstrap_external>\", line 850, in exec_module\n"," File\"<frozen importlib._bootstrap>\", line 228, in _call_with_frames_removed\n"," File\"/var/task/redshift.py\", line 3, in <module>\n conn = redshift_connector.connect(\n"," File\"/var/task/redshift_connector/__init__.py\", line 332, in connect\n IamHelper.set_iam_properties(info)\n"," File\"/var/task/redshift_connector/iam_helper.py\", line 117, in set_iam_properties\n IamHelper.set_iam_credentials(info)\n"," File\"/var/task/redshift_connector/iam_helper.py\", line 177, in set_iam_credentials\n IamHelper.set_cluster_credentials(provider, info)\n"," File\"/var/task/redshift_connector/iam_helper.py\", line 364, in set_cluster_credentials\n raise e\n"," File\"/var/task/redshift_connector/iam_helper.py\", line 319, in set_cluster_credentials\n client.get_credentials(**get_cred_args),\n"," File\"/var/task/botocore/client.py\", line 508, in _api_call\n return self._make_api_call(operation_name, kwargs)\n"," File\"/var/task/botocore/client.py\", line 878, in _make_api_call\n request_dict = self._convert_to_request_dict(\n"," File\"/var/task/botocore/client.py\", line 939, in _convert_to_request_dict\n request_dict = self._serializer.serialize_to_request(\n"," File\"/var/task/botocore/validate.py\", line 381, in serialize_to_request\n raise ParamValidationError(report=report.generate_report())\n" ]}and when i add the workgroupName i get a different error importredshift_connectorconn=redshift_connector.connect(iam=True,database="dev",host="1234567890.us-west-2.redshift-serverless.amazonaws.com",workgroupName="redshift",region='us-west-2')deflambda_handler(event,context):withconn.cursor()ascursor:cursor.execute("SELECT * FROM public.usertable;")result=cursor.fetchall()print(result) error after adding wrokgroupname {"errorMessage":"connect() got an unexpected keyword argument 'workgroupName'","errorType":"TypeError","requestId":"","stackTrace": [" File\"/var/lang/lib/python3.9/importlib/__init__.py\", line 127, in import_module\n return _bootstrap._gcd_import(name[level:], package, level)\n"," File\"<frozen importlib._bootstrap>\", line 1030, in _gcd_import\n"," File\"<frozen importlib._bootstrap>\", line 1007, in _find_and_load\n"," File\"<frozen importlib._bootstrap>\", line 986, in _find_and_load_unlocked\n"," File\"<frozen importlib._bootstrap>\", line 680, in _load_unlocked\n"," File\"<frozen importlib._bootstrap_external>\", line 850, in exec_module\n"," File\"<frozen importlib._bootstrap>\", line 228, in _call_with_frames_removed\n"," File\"/var/task/redshift.py\", line 3, in <module>\n conn = redshift_connector.connect(\n" ]}the workgroup is wrong the error message and i corrected it "WorkgroupName" {"errorMessage":"connect() got an unexpected keyword argument 'WorkgroupName'","errorType":"TypeError","requestId":"","stackTrace": [" File\"/var/lang/lib/python3.9/importlib/__init__.py\", line 127, in import_module\n return _bootstrap._gcd_import(name[level:], package, level)\n"," File\"<frozen importlib._bootstrap>\", line 1030, in _gcd_import\n"," File\"<frozen importlib._bootstrap>\", line 1007, in _find_and_load\n"," File\"<frozen importlib._bootstrap>\", line 986, in _find_and_load_unlocked\n"," File\"<frozen importlib._bootstrap>\", line 680, in _load_unlocked\n"," File\"<frozen importlib._bootstrap_external>\", line 850, in exec_module\n"," File\"<frozen importlib._bootstrap>\", line 228, in _call_with_frames_removed\n"," File\"/var/task/redshift.py\", line 3, in <module>\n conn = redshift_connector.connect(\n" ]} |
BetaWas this translation helpful?Give feedback.
All reactions
-
The first error you provided originates from boto3/botocore, not redshift-connector. This is why you see the second, Typically your serverless host name will have the workgroup present within it. Take for example: |
BetaWas this translation helpful?Give feedback.
All reactions
-
@Brooke-white thank you for the response . i did exactly what you mentioned and still got the same error. Best, |
BetaWas this translation helpful?Give feedback.
All reactions
-
@pruthvirajksuresh -- could you provide a code snippit showing how you're establishing a connection? |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
@Brooke-white hi, it tired the following 3 code , but none of them were successful thank you . trailoneimportredshift_connectordeflambda_handler(event,context):conn=redshift_connector.connect(iam=True,database="dev",host="redshift.123456789012.us-west-2.redshift-serverless.amazonaws.com",region="us-west-2", )withconn.cursor()ascursor:cursor.execute("SELECT * FROM public.usertable;")result=cursor.fetchall()print(result)trailtwoimportredshift_connectordeflambda_handler(event,context):conn=redshift_connector.connect(iam=True,database="dev",host="123456789012.us-west-2.redshift-serverless.amazonaws.com",region="us-west-2", )withconn.cursor()ascursor:cursor.execute("SELECT * FROM public.usertable;")result=cursor.fetchall()print(result)trailthreeimportredshift_connectordeflambda_handler(event,context):conn=redshift_connector.connect(iam=True,database="dev",host="123456789012.us-west-2.redshift-serverless.amazonaws.com",WorkgroupName="redshift",region="us-west-2", )withconn.cursor()ascursor:cursor.execute("SELECT * FROM public.usertable;")result=cursor.fetchall()print(result)trailfourimportredshift_connectordeflambda_handler(event,context):conn=redshift_connector.connect(iam=True,database="dev",WorkgroupName="redshift.123456789012.us-west-2.redshift-serverless.amazonaws.com",region="us-west-2", )withconn.cursor()ascursor:cursor.execute("SELECT * FROM public.usertable;")result=cursor.fetchall()print(result)trail5 [thisoneworksusingboto3library]importredshift_connectordeflambda_handler(event,context):client=boto3.client("redshift-data")response=client.execute_statement(WorkgroupName="redshift",Database="dev",Sql="SELECT * FROM public.usertable")print(response) |
BetaWas this translation helpful?Give feedback.
All reactions
-
there are usage issues with provided trails
Can you modify trail 1 by passing AWS credentials, either directly or via We have an example for redshift serverless connectionin our connection tutorial I also suggest to reviewconnection parameter docs for more details about these parameters and their usage. |
BetaWas this translation helpful?Give feedback.