Skip to content

Commit b0e9743

Browse files
authored
[Bugfix:Autograding] sql_runner w/ failed queries (#35)
* Make sql runner robust to failed queries * quick fix
1 parent 330852e commit b0e9743

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

examples/18_postgres_database/config/test_input/sql_runner.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,16 @@ def main():
8585
query = load_query(input_file)
8686
result = run_query(curr, query)
8787
cost, time = run_cost(curr, query)
88-
log_query_metrics(f"Query {num:d} run in {time:.3f} sec with cost {cost:.2f}")
89-
88+
conn.commit()
89+
log_query_metrics(f"Query {num:d} run in {time:.3f} sec with cost {cost:.2f}")
90+
9091
with open(output_file, 'w', newline='', encoding='utf-8') as result_file:
9192
writer = csv.writer(result_file, lineterminator='\n')
9293
writer.writerow([attr for attr in result[0].keys()])
9394
for t in result:
9495
writer.writerow(t)
9596
except:
97+
conn.rollback()
9698
err("Solution for %d raised exception %s" % (num, sys.exc_info()))
9799

98100

0 commit comments

Comments
 (0)