mycli icon indicating copy to clipboard operation
mycli copied to clipboard

How can i suppress column headings?

Open hiphamster opened this issue 5 years ago • 5 comments

If I'm exporting to csv, i don't need to see headings for every row. Thank you!

hiphamster avatar May 30 '20 22:05 hiphamster

Can you elaborate a little? Perhaps if you paste the current output and the desired output we can help you.

amjith avatar Jul 25 '20 03:07 amjith

I'll elaborate on what I'm looking for that brought me to this open issue... I'm trying to find the equivalent to the mysql commandline's --skip-column-names option.

Notably, when I enter mycli -e "tableformat csv; show status;" I get the following output:

"Variable_name","Value"
"Aborted_clients","96"
"Aborted_connects","45"
"Access_denied_errors","0"
...

I'd really like to avoid that top line of column headers. Thus brought me to an open issue discussing "suppress column headings".

wamcvey avatar Oct 08 '20 22:10 wamcvey

I'm looking for the same answer.

My intention is to export result of SELECT trace FROM information_schema.optimizer_trace; into a result.json file to investigate it further.

At the moment, I'm using these steps to generate the file:

\o -o result.json
\T plain
SELECT trace FROM information_schema.optimizer_trace;

However this still includes the name of the column in the result.json, making the JSON invalid:

trace
{
  "steps": [
  ...

The same question asked in Gitter chat: https://gitter.im/dbcli/mycli?at=5e41f921b612cc7bb15c7a9d

romanblanco avatar Feb 23 '21 07:02 romanblanco

Adding a parameter to exclude headers here might solve this:

https://github.com/dbcli/mycli/blob/51df80d25d7e7bd098bcda198b00e7e6fed7f706/mycli/sqlexecute.py#L272

romanblanco avatar Feb 23 '21 07:02 romanblanco

That's a lot of valid points. Let's make the following changes:

  1. options for the csv format. We already have csv and csv-tab, a better solution would be to have something like
csv --delimiter="\t" --headers=false
  1. minimal format, as suggested on gitter: the same as plain, but without column titles
  2. JSON format, maybe also with options.

gfrlv avatar Feb 23 '21 12:02 gfrlv