Skip to main content

SQL CLI Test and Build Latest Version Documentation Chat PyPi Downloads PRs welcome!

Open Distro for Elasticsearch SQL CLI

The SQL CLI component in Open Distro for Elasticsearch (ODFE) is a stand-alone Python application and can be launched by a 'wake' word odfesql.

It only supports Open Distro for Elasticsearch (ODFE) SQL Plugin You must have the ODFE SQL plugin installed to your Elasticsearch instance to connect. Users can run this CLI from MacOS and Linux, and connect to any valid Elasticsearch end-point such as Amazon Elasticsearch Service (AES).

Features

  • Multi-line input
  • Autocomplete for SQL syntax and index names
  • Syntax highlighting
  • Formatted output:
  • Tabular format
  • Field names with color
  • Enabled horizontal display (by default) and vertical display when output is too wide for your terminal, for better visualization
  • Pagination for large output
  • Connect to Elasticsearch with/without security enabled on either Elasticsearch OSS or Amazon Elasticsearch Service domains.
  • Supports loading configuration files
  • Supports all SQL plugin queries

Install

Launch your local Elasticsearch instance and make sure you have the Open Distro for Elasticsearch SQL plugin installed.

To install the SQL CLI:

  1. 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/activate
    
  2. Install the CLI:

    pip3 install odfe-sql-cli
    

    The SQL CLI only works with Python 3, since Python 2 is no longer maintained since 01/01/2020. See https://pythonclock.org/

  3. To launch the CLI, run:

    odfesql https://localhost:9200 --username admin --password admin
    

    By default, the odfesql command connects to http://localhost:9200.

Configure

When you first launch the SQL CLI, a configuration file is automatically created at ~/.config/odfesql-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 command odfesql is considered as the endpoint. If you do not provide an endpoint, by default, the SQL CLI connects to http://localhost:9200.
  • -u/-w: Supports username and password for HTTP basic authentication, such as:
  • --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, see clirc.

Using the CLI

  1. Save the sample accounts test data file.

  2. 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"
    
  3. Run a simple SQL command in ODFE SQL CLI:

    SELECT * FROM accounts;
    

    By default, you see a maximum output of 200 rows. To show more results, add a LIMIT clause with the desired value.

The CLI supports all types of query that ODFE SQL supports. Refer to ODFE SQL basic usage documentation.

Query options

Run single query from command line with options

  • --help: help page for options
  • -q: follow by a single query
  • -f: support jdbc/raw format output
  • -v: display data vertically
  • -e: translate sql to DSL

CLI 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 load

Code of Conduct

This project has adopted an Open Source Code of Conduct.

Security issue notifications

If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our vulnerability reporting page. Please do not create a public GitHub issue for security bugs you report.

Licensing

See the LICENSE file for our project's licensing. We will ask you to confirm the licensing of your contribution.

Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.

Metadata

Release files for odfe-sql-cli 1.13.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for odfe-sql-cli 1.13.0.0
File Size Uploaded Provenance
odfe-sql-cli-1.13.0.0.tar.gz 16.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for odfe-sql-cli 1.13.0.0
File Interpreter ABI Platform
odfe_sql_cli-1.13.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 41.8 kB

Release files / odfe-sql-cli-1.13.0.0.tar.gz

Download URL odfe-sql-cli-1.13.0.0.tar.gz
Size 16.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f5ac2ac65e2369a7ed5eb5f3ee1ececa3701f8b31e38aacb236baf95faf3c060
BLAKE2b-256 checksum
How to use checksums
3e983920535677b4ded5e10aa84f64ded287584e355f2ed7d9e90f57b5978227
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.7.4

Release files / odfe_sql_cli-1.13.0.0-py3-none-any.whl

Download URL odfe_sql_cli-1.13.0.0-py3-none-any.whl
Size 24.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
22b9b1c39930a4873ee2abfcf8371ea79f7773745b8fd0fe677baee592ed5438
BLAKE2b-256 checksum
How to use checksums
308c34f45c009cf16c73997082e7cae7321ef85c44564f9be3d9174c3d19d282
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.7.4

Security for odfe-sql-cli 1.13.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page