32 releases (8 breaking)

0.13.2 Feb 2, 2024
0.12.5 Jan 25, 2024
0.12.1 Dec 26, 2023
0.11.3 Nov 23, 2023

#207 in Database interfaces

Download history 4025/week @ 2023-10-31 3197/week @ 2023-11-07 2246/week @ 2023-11-14 2062/week @ 2023-11-21 3198/week @ 2023-11-28 2333/week @ 2023-12-05 2341/week @ 2023-12-12 1955/week @ 2023-12-19 1673/week @ 2023-12-26 2180/week @ 2024-01-02 1991/week @ 2024-01-09 2926/week @ 2024-01-16 2622/week @ 2024-01-23 2586/week @ 2024-01-30 930/week @ 2024-02-06 445/week @ 2024-02-13

7,210 downloads per month
Used in 3 crates (via databend-driver)


2.5K SLoC


Databend Native Client in Rust


  • core: Databend RestAPI rust client

  • driver: Databend unified SQL client for RestAPI and FlightSQL

  • cli: Databend native CLI

Installation for BendSQL


cargo-binstall is recommended:

cargo binstall bendsql

Or alternatively build from source:

cargo install bendsql


brew install databendcloud/homebrew-tap/bendsql


  • Using DEB822-STYLE format on 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
  • Using old format on Ubuntu-20.04/Debian-11 and earlier:
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

Then install bendsql:

sudo apt update

sudo apt install bendsql


Check for latest version on GitHub Release


❯ bendsql --help
Databend Native Command Line Tool

Usage: bendsql [OPTIONS]

      --help                     Print help information
      --flight                   Using flight sql protocol
      --tls                      Enable TLS
  -h, --host <HOST>              Databend Server host, Default:
  -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
      --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[=<TIME>]            Only show execution time without results, will implicitly set output format to `null`. [possible values: local, server]
  -V, --version                  Print version

Custom configuration

By default bendsql will read configuration from ~/.bendsql/config.toml and ~/.config/bendsql/config.toml sequentially if exists.

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

display_pretty_sql = true
progress_color = "green"
expand = "auto"
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.
max_width Limit display render box max width, 0 means default to the size of the terminal.
max_col_width Limit display render each column max width, smaller than 3 means disable the limit.
output_format The output format to use.
expand Expand table format display, default off, could be on/off/auto.
time Whether to show the time elapsed when executing queries.
multi_line Whether to allow multi-line input.
replace_newline whether replace '\n' with '\\n'.

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
:) .expand auto





  • databend://root:@localhost:8000/?sslmode=disable&presign=detect

  • databend://user1:password1@tnxxxx--default.gw.aws-us-east-2.default.databend.com:443/benchmark?enable_dphyp=1

  • databend+flight://root:@localhost:8900/database1?connect_timeout=10

Available Args:


Arg Description
tenant Tenant ID, Databend Cloud only.
warehouse Warehouse name, Databend Cloud only.
sslmode Set to disable if not using tls.
tls_ca_file Custom root CA certificate path.
connect_timeout Connect timeout in seconds

RestAPI client:

Arg Description
presigned_url_disabled Set to 1 to disable presigned upload to object storage, deprecated, use presign instead
wait_time_secs Request wait time for page, default to 1
max_rows_in_buffer Max rows for page buffer
max_rows_per_page Max response rows for a single page
page_request_timeout_secs Timeout for a single page request, default to 30
presign Whether to enable presign for data loading, available arguments are auto/detect/on/off, default to auto which only enable presign for Databend Cloud

FlightSQL client:

Arg Description
query_timeout Query timeout seconds
tcp_nodelay Default to true
tcp_keepalive Tcp keepalive seconds, default to 3600, set to 0 to disable keepalive
http2_keep_alive_interval Keep alive interval in seconds, default to 300
keep_alive_timeout Keep alive timeout in seconds, default to 20
keep_alive_while_idle Default to true

Query Settings:

see: Databend Query Settings


Cargo fmt, clippy, deny

make check

Unit tests

make test

integration tests

Note: Docker and Docker Compose needed

make integration


~612K SLoC