There are tests, other code in qiita_db/test/test_meta_util.py, etc. that are of the form: With TRN: sql = <something> results = execute(sql) return results or similar. This could be wrapped in a util function that reduces the amount of code repeats.