Code Monkey home page Code Monkey logo

databricks-sql-cli's Introduction

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 databricks-sql-cli

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

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.

databricks-sql-cli's People

Contributors

arikfr avatar susodapop avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.