Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Having access to raw results of the query would be handy #532

Open
boxofyellow opened this issue Oct 22, 2021 · 3 comments
Open

Having access to raw results of the query would be handy #532

boxofyellow opened this issue Oct 22, 2021 · 3 comments

Comments

@boxofyellow
Copy link

This might be a duplicate of #231, but that was closed as fixed referencing non-interactive output options. However that only talks about ways running in non-interactive mode and options to either send the results to file on standard out. That only gets us half the way there. Doing so still includes text in the result does not come from the query.

For example

mssql-cli -S *** -U *** -P *** -Q "SET NOCOUNT ON; SELECT name FROM sys.databases"

Yields this

Commands completed successfully.
+------------------------------------------+
| name                                     |
|------------------------------------------|
| master                                   |
| tempdb                                   |
| model                                    |
| msdb                                     |
| Azurite_Blob                             |
| Mps_Configuration                        |
| Mps_653f5e5a-3fbb-44be-9e61-be90630a7187 |
+------------------------------------------+
Commands completed successfully.

While correct, that make consuming this output more difficult. Ideally there would an option so that the above query would yield this output

master
tempdb
model
msdb
Azurite_Blob
Mps_Configuration
Mps_653f5e5a-3fbb-44be-9e61-be90630a7187

My example may be an over simplification, newlines may not always be the best delimiter 😄. So it may be handy to provide options to return the results in a standard format, here are a few that folks might find handy.
csv, tsv, json, yaml, xml, raw text

Most of the power of many command line tool does not come from running the tool in isolation, but instead comes from being able to combine it with other command line tools.

@freimer
Copy link

freimer commented Nov 18, 2021

You can change the format in the config file:
grep format ~/.config/mssqlcli/config

Table format. Possible values: psql, plain, simple, grid, fancy_grid, pipe,

table_format = csv

However, even if you select csv format and use -i -o options you still get the Commands completed successfully in the output, of the CSV file! That's totally unexpected and not proper.

@DevinSmithWork
Copy link

I'm also running into this issue. I'm following up the query with a command that deletes the first line of the CSV but I would love to not have to do this!

@bdmorin
Copy link

bdmorin commented Sep 1, 2022

I have SET NOCOUNT ON; at the top of my script and I exchanged (204 rows affected) for Commands completed successfully.

I mean, all i need to do is run it through awk, but still..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants