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
질문됨 5년 전1625회 조회
1개 답변
0
수락된 답변

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
중재자
답변함 5년 전
profile picture
전문가
검토됨 한 달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인