diff --git a/dune_client/api/extensions.py b/dune_client/api/extensions.py index 0eedbfc..91576e4 100644 --- a/dune_client/api/extensions.py +++ b/dune_client/api/extensions.py @@ -253,11 +253,13 @@ def run_sql( Requires Plus subscription! """ query = self.create_query(name, query_sql, params, is_private) - results = self.run_query( - query=query.base, performance=performance, ping_frequency=ping_frequency - ) - if archive_after: - self.archive_query(query.base.query_id) + try: + results = self.run_query( + query=query.base, performance=performance, ping_frequency=ping_frequency + ) + finally: + if archive_after: + self.archive_query(query.base.query_id) return results ######################