Call a stored procedure in Redshift from Glue

0

Hi all,

I am trying to work out if it possible to call a stored procedure in redshift from a glue script. Appreciate any advice.

AWS
gefragt vor 5 Jahren1625 Aufrufe
1 Antwort
0
Akzeptierte Antwort

This should be very similar to running any SQL command on Redshift through python. You could use a python-shell job which connects to Redshift to run a stored procedure. A python sample which shows how to connect to the Redshift cluster from python using psycopg2 library:

def loadfile(filename):
  conn_string = "dbname='dbname' port='port' user='user' password='password' host='host.eu-west-1.redshift.amazonaws.com'"
  conn = psycopg2.connect(conn_string)
  cursor = conn.cursor()
  cursor.execute("INSERT INTO tb_table (field1) VALUES ('field1')")
  conn.commit()
  cursor.close()
  return 

There are details on some more forums
https://www.quora.com/Can-I-connect-to-Redshift-using-Python
https://www.blendo.co/blog/access-your-data-in-amazon-redshift-and-postgresql-with-python-and-r/

AWS
MODERATOR
beantwortet vor 5 Jahren
profile picture
EXPERTE
überprüft vor einem Monat

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen