From 3c00175d827c24471888ad3b59e028360392652d Mon Sep 17 00:00:00 2001 From: Charlie Tonneslan Date: Mon, 18 May 2026 08:10:30 -0400 Subject: [PATCH] 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 --- sqlite_utils/cli.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sqlite_utils/cli.py b/sqlite_utils/cli.py index 5844dfc0..1fc6cfb9 100644 --- a/sqlite_utils/cli.py +++ b/sqlite_utils/cli.py @@ -236,7 +236,8 @@ def _iter(): 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: