Skip to main content

A DBCLI client for Databricks SQL

Project description

Introduction

Databricks SQL CLI is a command line interface (CLI) for Databricks SQL that can do auto-completion and syntax highlighting, and is a proud member of the dbcli community.

Quick Start

Install via pip

You'll need Python 3.7 or newer.

python3 -m pip install dbsqlcli

You can now run dbsqlcli from your terminal.

Authentication

To connect with SQL Endpoints dbsqlcli needs the host name and http path from the connection details screen in Databricks SQL and a personal access token. You can provide these to dbsqlcli as command line arguments, by setting environment variables, or by writing them into the [credentials] section of the dbsqlclirc file (see below).

Config

A config file is automatically created at ~/.dbsqlcli/dbsqlclirc at first launch (run dbsqlcli). See the file itself for a description of all available options.

Run a query

$ dbsqlcli -e 'select id, name from minifigs LIMIT 10'

Run a .sql file

$ dbsqlcli -e query.sql

Run a .sql file and save to CSV

$ dbsqlcli -e query.sql > output.csv

REPL

$ cd <directory containing dbsqlcli binary>
$ ./dbslqcli [<database_name>]

Run the help; command to see a list of shortcuts

Features

  • Auto-completes as you type for SQL keywords as well as tables and columns in the database.
  • Syntax highlighting.
  • Smart-completion will suggest context-sensitive completion.
    • SELECT * FROM <tab> will only show table names.
    • SELECT * FROM users WHERE <tab> will only show column names.
  • Pretty prints tabular data and various table formats.
  • Some special commands. e.g. Favorite queries.
  • Alias support. Column completions will work even when table names are aliased.

Usages

$ dbsqlcli --help
Usage: dbsqlcli [OPTIONS] [DATABASE]

  A DBSQL terminal querying client with auto-completion and syntax
  highlighting.

  Examples:
    - dbsqlcli
    - dbsqlcli my_database

Options:
  -e, --execute TEXT   Execute a command (or a file) and quit.
  --hostname TEXT      Hostname  [env var: DBSQLCLI_HOST_NAME]
  --http-path TEXT     HTTP Path  [env var: DBSQLCLI_HTTP_PATH]
  --access-token TEXT  Access Token  [env var: DBSQLCLI_ACCESS_TOKEN]
  --clirc FILE         Location of clirc file.
  --table-format TEXT  Table format used with -e option.
  --help               Show this message and exit.

Contributions

During its internal release, please report issues in the #dbsqlcli Slack channel.

We use Poetry for development. Follow the instructions to install Poetry on your system.

  1. Clone this repository
  2. poetry install will install its dependencies
  3. poetry shell will activate the local virtual environment
  4. python app.py will run dbsqlcli incorporating any of your local changes

Credits

Huge thanks to the maintainers of https://github.com/dbcli/athenacli upon which this project is built.

Similar projects

The DBCLI organization on Github maintains CLIs for numerous database platforms including MySQL, Postgres, and MSSQL.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

databricks-sql-cli-0.1.2.tar.gz (41.3 kB view details)

Uploaded Source

Built Distribution

databricks_sql_cli-0.1.2-py3-none-any.whl (48.0 kB view details)

Uploaded Python 3

File details

Details for the file databricks-sql-cli-0.1.2.tar.gz.

File metadata

  • Download URL: databricks-sql-cli-0.1.2.tar.gz
  • Upload date:
  • Size: 41.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.10.2 Linux/5.13.0-1022-azure

File hashes

Hashes for databricks-sql-cli-0.1.2.tar.gz
Algorithm Hash digest
SHA256 1cc69213ef6f166f1c439d05204121037478ab393e50b0365f07c5ce02dc5990
MD5 ab19e09cca39657bc4774620ab0a4230
BLAKE2b-256 d810282ab04c6f2bd03f699097e1feaec67d6e0dd3387f842d42d9ca9529b87d

See more details on using hashes here.

File details

Details for the file databricks_sql_cli-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: databricks_sql_cli-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 48.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.10.2 Linux/5.13.0-1022-azure

File hashes

Hashes for databricks_sql_cli-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 14032b375d11ec8e9243e3f05d8d080813b7a8566709dfe5fe6ac7cca2860a08
MD5 d83c3392f78f3b1e3b3e446074bc181d
BLAKE2b-256 2d4b6ca6169f71eb78b96c1b4b68feba6ad293c9746243b5456c3adcdc70b64a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page