Skip to content

youngsofun/bendsql

 
 

Repository files navigation

BendSQL

Databend Native Client in Rust

Components

  • core: Databend RestAPI rust client

  • driver: Databend unified SQL client for RestAPI and FlightSQL

  • cli: Databend native CLI

Installation for BendSQL

  • Cargo:
cargo install bendsql
  • Homebrew:
brew install databendcloud/homebrew-tap/bendsql
  • Apt:
sudo curl -L -o /usr/share/keyrings/datafuselabs-keyring.gpg https://repo.databend.rs/deb/datafuselabs.gpg
sudo curl -L -o /etc/apt/sources.list.d/datafuselabs.list https://repo.databend.rs/deb/datafuselabs.list

# or using DEB822-STYLE format in Ubuntu-22.04/Debian-12 and later
# sudo curl -L -o /etc/apt/sources.list.d/datafuselabs.sources https://repo.databend.rs/deb/datafuselabs.sources

sudo apt update

sudo apt install bendsql
  • Binary: check for latest release here

Usage

❯ bendsql --help
Databend Native Command Line Tool

Usage: bendsql [OPTIONS]

Options:
      --help                     Print help information
      --flight                   Using flight sql protocol
      --tls                      Enable TLS
  -h, --host <HOST>              Databend Server host, Default: 127.0.0.1
  -P, --port <PORT>              Databend Server port, Default: 8000
  -u, --user <USER>              Default: root
  -p, --password <PASSWORD>      [env: BENDSQL_PASSWORD=]
  -D, --database <DATABASE>      Database name
      --set <SET>                Settings
      --dsn <DSN>                Data source name [env: BENDSQL_DSN=]
  -n, --non-interactive          Force non-interactive mode
  -q, --query <QUERY>            Query to execute
  -d, --data <DATA>              Data to load, @file or @- for stdin
  -f, --format <FORMAT>          Data format to load [default: csv] [possible values: csv, tsv, ndjson, parquet, xml]
      --format-opt <FORMAT_OPT>  Data format options
  -o, --output <OUTPUT>          Output format [possible values: table, csv, tsv, null]
      --progress                 Show progress for query execution in stderr, only works with output format `table` and `null`.
      --stats                    Show stats after query execution in stderr, only works with non-interactive mode.
      --time                     Only show execution time without results, will implicitly set output format to `null`.
  -V, --version                  Print version

Custom configuration

By default bendsql will read configuration from ~/.config/bendsql/config.toml if the file exists.

  • Example file
❯ cat ~/.config/bendsql/config.toml
[connection]
connect_timeout = "30s"


[settings]
display_pretty_sql = true
progress_color = "green"
prompt = ":) "

  • Connection section
Parameter Description
host Server host to connect.
port Server port to connect.
user User name.
database Which database to connect.
args Additional connection args.
  • Settings section
Parameter Description
display_pretty_sql Whether to display SQL queries in a formatted way.
prompt The prompt to display before asking for input.
progress_color The color to use for the progress bar.
show_progress Whether to show a progress bar when executing queries.
show_stats Whether to show statistics after executing queries.
max_display_rows The maximum number of rows to display in table output format.
output_format The output format to use.
time Whether to show the time elapsed when executing queries.
multi_line Whether to allow multi-line input.

Control commands in REPL

We can use .CMD_NAME VAL to update the Settings above in runtime, example:

❯ bendsql

:) .display_pretty_sql false
:) .max_display_rows 10

Development

Cargo fmt, clippy, audit

make check

Unit tests

make test

integration tests

Note: Docker and Docker Compose needed

make integration

About

Databend Native Client

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 96.9%
  • Shell 1.5%
  • Other 1.6%