mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-18 14:34:24 +02:00
cli: honor --no-headers for table and tabulate-style formats
--no-headers was already wired up for csv/tsv output but the tabulate.tabulate calls (used for --table and --fmt) passed headers unconditionally, so the header row still printed. Pass () to tabulate in that case to suppress it. Closes #566 Signed-off-by: Charlie Tonneslan <cst0520@gmail.com>
This commit is contained in:
parent
8f0c06e188
commit
3c00175d82
1 changed files with 4 additions and 2 deletions
|
|
@ -236,7 +236,8 @@ def tables(
|
|||
yield row
|
||||
|
||||
if table or fmt:
|
||||
print(tabulate.tabulate(_iter(), headers=headers, tablefmt=fmt or "simple"))
|
||||
tab_headers = () if no_headers else headers
|
||||
print(tabulate.tabulate(_iter(), headers=tab_headers, tablefmt=fmt or "simple"))
|
||||
elif csv or tsv:
|
||||
writer = csv_std.writer(sys.stdout, dialect="excel-tab" if tsv else "excel")
|
||||
if not no_headers:
|
||||
|
|
@ -2137,9 +2138,10 @@ def _execute_query(
|
|||
else:
|
||||
sys.stdout.write(str(data) + "\n")
|
||||
elif fmt or table:
|
||||
tab_headers = () if no_headers else headers
|
||||
print(
|
||||
tabulate.tabulate(
|
||||
list(cursor), headers=headers, tablefmt=fmt or "simple"
|
||||
list(cursor), headers=tab_headers, tablefmt=fmt or "simple"
|
||||
)
|
||||
)
|
||||
elif csv or tsv:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue