amazon-redshift

Return data from Python's Redshift procedure call

Return data from Python's Redshift procedure call Question: redshift_connector is defined to be aligned with https://peps.python.org/pep-0249/#id24 but I can’t, after calling procedure, retrieve data into a dataframe. Instead I’m getting ‘mycursor’ value. How to overcome this? fetch*() methods don’t allow passing argument that will allow getting into data in mycursor. I also tried RECORDS type …

Total answers: 2

Push data to Campaign Monitor using Python

Push data to Campaign Monitor using Python Question: Campaign Monitor is a service where we can send emails to a set of subscribers. We can create multiple lists within Campaign Monitor and add the required users to these lists as subscribers(to whom we can send personalised emails). So, here I am trying to send a …

Total answers: 1

Returning result set from redshift stored procedure

Returning result set from redshift stored procedure Question: I have a procedure that returns a recordset using the cursor method: CREATE OR REPLACE PROCEDURE myschema.permissions_sp(rs_out INOUT refcursor) LANGUAGE plpgsql SECURITY DEFINER AS $$ BEGIN OPEN rs_out FOR select schema_name,schema_owner,grantee_type,grantee,p_usage,p_create,object_name,perms,p_select,p_update,p_insert,p_delete,p_truncate,p_references,p_trigger,p_rule from xxxx.myview; END; $$ / GRANT EXECUTE on PROCEDURE myschema.permissions_sp(INOUT refcursor) TO xxxx_user / And I …

Total answers: 1

Redshift python connector columns names are byte string

Redshift python connector columns names are byte string Question: Suppose I have the following table in redshift: a | b —– 1 | 2 3 | 4 If I want to extract it from Redshift to a pd.DataFrame I can do the following: import redshift_connector import pandas as pd query = ‘SELECT * FROM table’ …

Total answers: 2

How to check if a aws redshift table is present or not

How to check if a aws redshift table is present or not Question: I have an use case where I need to do the followings: 1.Check if redshift_db.redhsift_tbl is present or not? If table is present then perform operation A else perform operation B. I was checking in boto3 documentation to get an api which …

Total answers: 2

Create Redshift table with new Geometry type through psycopg2

Create Redshift table with new Geometry type through psycopg2 Question: After Redshift announced support for Geometry types and spatial functions, I’d like to create a table with polygons for all countries. I’m failing to do the INSERT and would appreciate help. Here is what I’ve tried: I’ve downloaded the geojson and unzipped (https://datahub.io/core/geo-countries) Then the …

Total answers: 4

Sql Alchemy cannot run inside a transaction block

Sql Alchemy cannot run inside a transaction block Question: I’m trying to run a query in redshift from a python script, but I’m getting error: sqlalchemy.exc.InternalError: (psycopg2.InternalError) ALTER EXTERNAL TABLE cannot run inside a transaction block This is my code: engine = create_engine(SQL_ENGINE % urlquote(REDSHIFT_PASS)) partition_date = (date.today() – timedelta(day)).strftime(“%Y%m%d”) query = “””alter table {table_name} …

Total answers: 3