From: Karl O. Pinc Date: Sat, 5 Oct 2024 01:03:14 +0000 (-0500) Subject: Test outside of loop X-Git-Url: https://papio.biology.duke.edu/gitweb/?a=commitdiff_plain;h=80ffc501c431ad777100180bccdbfaef9f954f91;p=pgwui_sql Test outside of loop --- diff --git a/src/pgwui_sql/views/sql.py b/src/pgwui_sql/views/sql.py index 2c6b665..52e531c 100644 --- a/src/pgwui_sql/views/sql.py +++ b/src/pgwui_sql/views/sql.py @@ -337,24 +337,23 @@ class SQLResultsHandler(pgwui_core.core.SessionDBHandler): csv_writer = self.write_sql() nextset = True - download_as = self.uf['download_as'] - stmt_no = 1 - while nextset is True: - if download_as == MANY_FILES_VALUE: + if self.uf['download_as'] == MANY_FILES_VALUE: + stmt_no = 1 + while nextset is True: with zipfile.Path( self.zip_fd, at=self.zip_at_pathname(f'stmt{stmt_no}.txt') ).open(mode='w', newline='') as fd: self.write_resultset( cur, self.make_csv_writer(fd), null_rep) + nextset = cur.nextset() stmt_no += 1 - else: + self.zip_fd.close() + else: + while nextset is True: self.write_resultset(cur, csv_writer, null_rep) + nextset = cur.nextset() - nextset = cur.nextset() - - if download_as == MANY_FILES_VALUE: - self.zip_fd.close() self.tfile.seek(0) def make_sql_results(self, cur):