如何从 Glue 调用 Redshift 中的存储过程

0

【以下的问题经过翻译处理】 大家好,

我正在尝试找出是否可以从Glue脚本调用Redshift中的存储过程。

感谢任何建议。

profile picture
전문가
질문됨 5달 전19회 조회
1개 답변
0

【以下的回答经过翻译处理】 这应该与通过 python 在 Redshift 上运行任何 SQL 命令非常相似。您可以使用连接到 Redshift 的 python-shell 作业来运行存储过程。一个 python 示例,它显示了如何使用 psycopg2 库从 python 连接到 Redshift 集群:

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 

这个link中还有一些细节 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/

profile picture
전문가
답변함 5달 전

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

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

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