This post is authored by Alan Yu, Program Manager, SQL Server.
We are excited to announce the Public Preview release of mssql-cli, a new and interactive command line query tool for SQL Server. This open source tool works cross-platform and is a proud member of the dbcli community.
See the install guide to download mssql-cli and get started.
Read on to learn more about mssql-cli features, how to submit feature requests or issues, and our open source collaboration story to bring you this great tool.
mssql-cli auto-completion that is context aware
Mssql-cli is a new and interactive command line tool that provides the following key enhancements over sqlcmd in the Terminal environment:
- T-SQL IntelliSense
- Syntax highlighting
- Pretty formatting for query results, including Vertical Format
- Multi-line edit mode
- Configuration file support
Mssql-cli aims to offer an improved interactive command line experience for T-SQL. It is fully open source under the BSD-3 license, and a contribution to the dbcli organization, an open source suite of interactive CLI tools for relational databases including SQL Server, PostgresSQL, and MySQL. The command-line UI is written in Python and the tool leverages the same microservice backend (sqltoolsservice) that powers the VS Code SQL extension, SQL Operations Studio, and the other Python CLI tool we announced earlier, mssql-scripter.
mssql-cli multi-line queries to build readable queries. Also includes syntax highlighting and “smart” auto-completion.
Try it now
In order to install mssql-cli, you must have Python on your machine. Please refer to the installation guide for OS-specific methods to get Python.
Mssql-cli is installed via pip. If you know pip, you can install mssql-cli using command.
$ pip install mssql-cli
This command may need to run as sudo if you are installing to the system site packages. Mssql-cli can be installed using the –user option, which does not require sudo.
$ pip install --user mssql-cli
If you are having installation issues or would like more specific instructions, please see the installation guide.
Once you have mssql-cli installed, connect to your database with the command:
$ mssql-cli -S <server name> -U <user name> -d <database name>
We are open to any questions, feedback, or any feature suggestions for future releases, which can be submitted on our GitHub Issues.
Our Open Source Story
Over the years, customers have told us we need to modernize sqlcmd. This feedback got significantly amplified after SQL Server 2017 was released on Linux and macOS (Docker). Customers asked us for richer experiences on the command line including tab completion for T-SQL keywords and database objects and syntax highlighting.
Thus, the SQL Developer Experiences team set out to create a modern version of sqlcmd. As we worked through our scenarios, we discovered an awesome and immensely popular set of open source command line tools for databases on GitHub at https://github.com/dbcli maintained by the dbcli organization. The repo contains open source cross-platform CLI tools for databases, which support “smart” auto-completion, syntax highlighting and easy installation. We were particularly impressed with the pgcli and mycli tools, as well as how active and passionate their community was in creating better database cli tools.
We reached out to Amjith Ramanujam, the founder of the dbcli organization, did an in-depth demo, explained what we were trying to do, and explored if mssql-cli could be included in the dbcli family. Simply put, Amjith and the other maintainers of the project were delighted and welcomed us with open arms!
This is a momentous occasion for the SQL Developer Experiences team because it represents the first time our team is contributing source code to an existing open source organization with a commitment to be a good citizen in an existing open source community. It is also an exciting moment to build an awesome tool by collaborating with the OSS community, which we will continue to do in the future.
Source: Microsoft Blog – SQL Server News – Try mssql-cli, a new interactive command line tool for SQL Server