Programmatically Running a Stored Procedure in Redshift

0

Is there a way to run a stored procedure on a schedule? I have a series of updates/inserts and an unload that i would want to run programmatically. I haven’t written those queries as a stored procedure yet because I want to first see if it can be run / called programmatically or if it’s something that glue would have to do? Where can I look to figure out how to do this?

jbw12
질문됨 5년 전2264회 조회
6개 답변
0

Is there a way to run a stored procedure on a schedule?

Not within Redshift itself.

You need to configure an external system, such as an EC2 instance, to regularly connect to and issue your SQL on the Redshift instance.

This is usually done with a crontab and something like a Python script.

A stored procedure can be called programmatically; it's just an SQL statement, like any other. If your queries run correctly without needing the functionality of a procedure, there's no particular need to make a procedure. Just issue your SQL from Python.

Toebs2
답변함 5년 전
0

May I know if you were able to setup your SQL scripts/ stored proc run on a schedule?
I have a similar scenario and looking for options to achieve it.

Thanks,
Patravik

답변함 5년 전
0

AWS Glue provides time based scheduling of jobs. You could use a small Python script to connect to Redshift and call the Stored Procedure.
• Time-Based Schedules:https://docs.aws.amazon.com/glue/latest/dg/monitor-data-warehouse-schedule.html
• Adding Python Shell Jobs: https://docs.aws.amazon.com/glue/latest/dg/add-job-python.html

You can also schedule events with Amazon EventBridge. Redshift is not currently an EventBridge target however you can invoke a Lamba function which calls the Redshift Stored Procedure.
• Tutorial: https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/RunLambdaSchedule.html

답변함 5년 전
0

Thanks for the response. I created a sample stored proc through Redshift query editor but do not seem to find where to access it from. Is there a place where I can see the list of stored procs created?

답변함 5년 전
0

I also responded to your post on that here: https://forums.aws.amazon.com/thread.jspa?threadID=310998&tstart=0

답변함 5년 전
0

thanks

답변함 5년 전

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

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

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

관련 콘텐츠