Package: opensearchsql
OpenSearch SQL CLIThe SQL CLI component in OpenSearch is a stand-alone Python application and can be launched by a 'wake' wordopensearchsql.It only supportsOpenSearch SQL PluginYou must have the OpenSearch SQL plugin installed to your OpenSearch instance to connect.
Users can run this CLI from Unix like OS or Windows, and connect to any valid OpenSearch end-point such as Amazon OpenSearch Service.FeaturesMulti-line inputAutocomplete for SQL syntax and index namesSyntax highlightingFormatted output:Tabular formatField names with colorEnabled horizontal display (by default) and vertical display when output is too wide for your terminal, for better visualizationPagination for large outputConnect to OpenSearch with/without security enabled on eitherOpenSearch or Amazon OpenSearch Service domains.Supports loading configuration filesSupports all SQL plugin queriesVersionUnlike plugins which use 4-digit version number. SQl-CLI usesx.x.xas version number same as other python packages in OpenSearch family. As a client for OpenSearch SQL, it has independent release.
SQL-CLI should be compatible to all OpenSearch SQL versions. However since the codebase is in a monorepo,
so we'll cut and name sql-cli release branch and tags differently. E.g.release branch: sql-cli-1.0
release tag: sql-cli-v1.0.0InstallLaunch your local OpenSearch instance and make sure you have the OpenSearch SQL plugin installed.To install the SQL CLI:We suggest you install and activate a python3 virtual environment to avoid changing your local environment:pip install virtualenv
virtualenv venv
cd venv
source ./bin/activateInstall the CLI:pip3 install opensearchsqlThe SQL CLI only works with Python 3, since Python 2 is no longer maintained since 01/01/2020. Seehttps://pythonclock.org/To launch the CLI, run:opensearchsql https://localhost:9200 --username admin --password adminBy default, theopensearchsqlcommand connects tohttp://localhost:9200.ConfigureWhen you first launch the SQL CLI, a configuration file is automatically created at~/.config/opensearchsql-cli/config(for MacOS and Linux), the configuration is auto-loaded thereafter.You can also configure the following connection properties:endpoint: You do not need to specify an option, anything that follows the launch commandopensearchsqlis considered as the endpoint. If you do not provide an endpoint, by default, the SQL CLI connects tohttp://localhost:9200.-u/-w: Supports username and password for HTTP basic authentication, such as:OpenSearch withOpenSearch Security PlugininstalledAmazon OpenSearch Service domain withFine Grained Access Controlenabled--aws-auth: Turns on AWS sigV4 authentication to connect to an Amazon Elasticsearch Service endpoint. Use with the AWS CLI (aws configure) to retrieve the local AWS configuration to authenticate and connect.For a list of all available configurations, seeclirc.Using the CLISave the sampleaccounts test datafile.Index the sample data.curl -H "Content-Type: application/x-ndjson" -POST https://localhost:9200/data/_bulk -u admin:admin --insecure --data-binary "@accounts.json"Run a simple SQL command in OpenSearch SQL CLI:SELECT * FROM accounts;By default, you see a maximum output of 200 rows. To show more results, add aLIMITclause with the desired value.The CLI supports all types of query that OpenSearch SQL supports. Refer toOpenSearch SQL basic usage documentation.Query optionsRun single query from command line with options--help: help page for options-q: follow by a single query-f: supportjdbc/rawformat output-v: display data vertically-e: translate sql to DSLCLI Options-l: Query language option. Available options are [sql, ppl]. By default it's using sql.-p: always use pager to display output--clirc: provide path of config file to loadCode of ConductThis project has adopted anOpen Source Code of Conduct.Security issue notificationsIf you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via ourvulnerability reporting page. Please donotcreate a public GitHub issue for security bugs you report.LicensingSee theLICENSEfile for our project's licensing. We will ask you to confirm the licensing of your contribution.CopyrightCopyright OpenSearch Contributors. SeeNOTICEfor details.