Hi everyone! I am browsing the documentation in or...
# ask-community
p
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
hello! it seems I have a similar situation what kind of queries do you need to run? is is against Salesforce endpoint?
p
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
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
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.