Tweak how output of rattail runsql command is handled

to avoid "scientific notation" formatting for UPC
This commit is contained in:
Lance Edgar 2020-02-20 16:54:05 -06:00
parent abf9f95478
commit 4ebd4b31d6

View file

@ -1308,7 +1308,15 @@ class RunSQL(Subcommand):
rows = result.fetchall() rows = result.fetchall()
if rows: if rows:
table = texttable.Texttable(max_width=args.max_width) table = texttable.Texttable(max_width=args.max_width)
# force all columns to be treated as text. that seems a bit
# heavy-handed but is definitely the simplest way to deal with
# issues such as a UPC being displayed in scientific notation
table.set_cols_dtype(['t' for col in rows[0]])
# add a header row, plus all data rows
table.add_rows([rows[0].keys()] + rows) table.add_rows([rows[0].keys()] + rows)
self.stdout.write("{}\n".format(table.draw())) self.stdout.write("{}\n".format(table.draw()))