1

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?

I know that stored procedures in Redshift are very new. I'm currently executing my code in Pycharm Professional and I've been able to create and run a simple stored procedure.

My updates & inserts (before writing them as a stored procedure) are very similar to the formats specified in Performing a Merge operation by specifying a column list - Amazon Redshift.

Any help will be much appreciated? Are there any references that you could share?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
JBW12
  • 11
  • 1
  • 2
  • check this out https://stackoverflow.com/questions/64775753/how-to-run-arbitrary-ddl-sql-statements-or-stored-procedures-using-aws-glue – mishkin Jan 21 '21 at 19:12

1 Answers1

1

You would need to run some code externally that triggers the stored procedure.

For example, an AWS Lambda function can be configured to run on a schedule. It could then use psycopg2 to connect to the Amazon Redshift cluster and execute an SQL command to run the stored procedure.

Alternatively, if you have Amazon EC2 instances running, you could use a cron job to run a psql command that connects and runs an SQL command.

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470