cli_helpers icon indicating copy to clipboard operation
cli_helpers copied to clipboard

Added skip_headers argument to the csv formatter

Open gfrlv opened this issue 4 years ago • 2 comments

Description

A new argument is needed to implement \T csv --skip-headers in mycli, see https://github.com/dbcli/mycli/issues/872

Checklist

  • [x] I've added this contribution to the CHANGELOG.
  • [x] I've added my name to the AUTHORS file (or it's already there).
  • [x] I installed pre-commit hooks (pip install pre-commit && pre-commit install), and ran black on my code.
  • [x] Please squash merge this pull request (uncheck if you'd like us to merge as multiple commits)

gfrlv avatar Feb 23 '21 20:02 gfrlv

@pasenor Is this still relevant, or not anymore (superseded by https://github.com/dbcli/cli_helpers/pull/74)?

j-bennet avatar Aug 27 '21 20:08 j-bennet

I've been working with SQL queries and shell commands to process the output, specifically aiming to retrieve results without headers. Consider the following example:

SELECT
    5 >= 0
    AND 5 <= 10;

To eliminate the header from the output, I used sed with the mycli command:

mycli --csv --no-warn -e '\n; \. script.sql' mariadb://mysql@localhost/test | sed '1d'

The resulting data output is as follows:

        AND 5 <= 10"
"1"

From this, it's clear that while we can manipulate the output to exclude the header, the process isn't as straightforward or clean as it could be. I believe implementing a feature that allows for direct output without headers would greatly enhance usability and efficiency. What are your thoughts on exploring this feature further?

Lidoca avatar Apr 03 '24 08:04 Lidoca