go-sqlcmd icon indicating copy to clipboard operation
go-sqlcmd copied to clipboard

Consider using go-prompt to enable a nice interactive prompt like mssql-cli

Open daviewales opened this issue 1 year ago • 10 comments
trafficstars

mssql-cli has a nice prompt and nice table output thanks to the use of the following Python libraries:

mssql-cli is on the deprecation track, and suggests that go-sqlcmd is the future. It would be nice if go-sqlcmd copied some of the nice usability features from mssql-cli.

There are existing Go libraries inspired by Python Prompt Toolkit and Tabulate which may help improve the go-sqlcmd interface similar to mssql-cli:

Tabulate inspired libraries:

  • https://github.com/markkurossi/tabulate
  • https://github.com/rgeoghegan/tabulate
  • https://github.com/bndr/gotabulate

Non-tabulate-inspired table library:

  • https://github.com/jedib0t/go-pretty

Python Prompt Toolkit inspired library:

  • https://github.com/c-bata/go-prompt

Would go-sqlcmd consider implementing some of these usability features?

daviewales avatar Nov 23 '23 00:11 daviewales

I would also like to see go-sqlcmd implement more of the functionality that is available in mssql-cli and the other tools in the dbcli family (https://github.com/dbcli).

  • Tab completion of table names and other object names
  • show long output in a user-configurable pager
  • ability to transpose records like postgres psql's \x command
  • in interactive sessions, have a setting to invoke a statement without having to put GO on a newline

michaelstack avatar Dec 12 '23 05:12 michaelstack

thx for the input! Regarding transpose records is that similar to sqlcmd -F vertical ?

shueybubbles avatar Dec 12 '23 15:12 shueybubbles

+1 to this request, very happy using mssql-cli to discover and walk through tables, would hate to lose that interactive element of being able to do this in a terminal

Coding-Journey avatar Jan 30 '24 14:01 Coding-Journey

@shueybubbles

Regarding transpose records is that similar to sqlcmd -F vertical ?

Yes, and it is also like these:

:setvar SQLCMDFORMAT vertical
:setvar SQLCMDFORMAT horizontal

The advantage of psql's \x command is that it is much easier to type. Plus the one single command toggles the setting, as opposed to two separate commands.

Psql also has \x auto, which will automatically switch based on the width of the records selected.

This automatic behaviour is included in pgcli under the auto_expand setting:

https://github.com/dbcli/pgcli/blob/96eb37fd1989ec8fd86150f20053abd03f50e7a4/pgcli/pgclirc#L51

Looks like it was included in mssql-cli also with the expand setting:

https://github.com/dbcli/mssql-cli/blob/67a3a4364383d11776bb0a397ceae7bc19200e41/mssqlcli/mssqlclirc#L29

michaelstack avatar Feb 20 '24 05:02 michaelstack

+1

pietdaniel avatar Mar 21 '24 20:03 pietdaniel

+1

azinsharaf avatar Mar 28 '24 23:03 azinsharaf

I think this is not ready to replace mssql-cli yet if tab-completion is not supported. This capabilities make using DB CLI tool a comparable alternative to full-fleshed DB tool such as DBeaver.

AnhQuanTrl avatar Apr 06 '24 15:04 AnhQuanTrl

i checked usql cli and it had some tab completion capabilities. i haven't spent enough time to check it throughly.

azinsharaf avatar Apr 06 '24 16:04 azinsharaf