https://dagster.io/ logo
#ask-community
Title
# ask-community
p

Peter Fulop

04/24/2023, 12:06 PM
Hi everyone! I am browsing the documentation in order to find and example of multiple queries that runs within/as a single transaction in Snowflake. Important: these queries run in sequence, they might use each other results(changes). Can any of you send me a short example of running queries as a transaction (they are part of the same op)
Copy code
...
context.resources.sf_resource.execute_query(query_1)
context.resources.sf_resource.execute_query(query_2)
...
a

Arsenii Poriadin

04/24/2023, 1:28 PM
hello! it seems I have a similar situation what kind of queries do you need to run? is is against Salesforce endpoint?
p

Peter Fulop

04/24/2023, 1:47 PM
I realized after reading your question that I needed to be more specific with this. It is connected to Snowflake. In the meanwhile, I managed to devise a workaround. The commit and rollback features are available in the Dagsters Snowflake resource. Therefore, I'll set auto-commit to false and manually commit and rollback (as needed).
t

Tim Castillo

04/24/2023, 5:45 PM
Hi! Setting auto-commit to false is a valid workaround. Is there are reason why you have multiple
execute_query
calls? If you'd like transactional safety, would you be able to concatenate your strings together and wrap them in a transaction in that string?
p

Peter Fulop

04/24/2023, 9:03 PM
Thanks for the feedback. Yes, the second query is using the information (updated values) of the first one. The business logic requires to do a rollback whenever one of the queries fail.
5 Views