return csv.writer(fd, dialect=csv.excel_tab)
def write_sql(self):
- if self.uf['include_sql']:
- if self.uf['download_as'] == MANY_FILES_VALUE:
- with zipfile.Path(
- self.zip_fd,
- at=self.zip_at_pathname('statements.txt')
- ).open(mode='wb') as fd:
- fd.write(self.uf['sql'].encode())
- return None
- else:
- writer = self.make_csv_writer()
+ if self.uf['download_as'] == MANY_FILES_VALUE:
+ with zipfile.Path(
+ self.zip_fd,
+ at=self.zip_at_pathname('statements.txt')
+ ).open(mode='wb') as fd:
+ fd.write(self.uf['sql'].encode())
+ else:
+ writer = self.make_csv_writer()
+ if self.uf['include_sql']:
# Strip trailing whitespace from sql because otherwise,
# after import to a spreadsheet with cells a single row tall,
# only the empty line after the last EOL is shown and the
# first cell of the sheet looks empty instead of looking like
# it contains the sql.
writer.writerow((self.uf['sql'].rstrip(),))
- return writer
+ return writer
def write_resultset(self, cur, writer, null_rep):
# Rather than report the statusmessage first, which requires
# Optimized to minimize RAM usage
null_rep = self.uf['null_rep']
self.open_tfile()
- writer = self.write_sql()
+ csv_writer = self.write_sql()
nextset = True
download_as = self.uf['download_as']
cur, self.make_csv_writer(fd), null_rep)
stmt_no += 1
else:
- self.write_resultset(cur, writer, null_rep)
+ self.write_resultset(cur, csv_writer, null_rep)
nextset = cur.nextset()