A REPL for the Materialize Streaming Database Engine
See https://materialize.com for an introduction to Materialize.
Quick Start
The easiest way to get started with mzcli with a remote materialized is to use docker:
docker run -it materialize/mzcli mzcli --help
Or you can install mzcli using pip or pipx (recommended):
pipx install mzcli
This is a work-in-progress materialize client that does auto-completion and
syntax highlighting. It is a soft fork of pgcli, and will hopefully one day be
even less of a fork from mzcli, but due to materialize's extra functionality
this will be a long-lived tool for interacting with materialized.


Finding the Latest Version
New releases of mzcli are automatically built from main and published
to Docker Hub.
Usage
$ mzcli [database_name]
or
$ mzcli postgresql://[user[:password]@][netloc][:port][/dbname][?extra=value[&other=other-value]]
Examples:
$ mzcli local_database
$ mzcli postgres://amjith:pa$$w0rd@example.com:5432/app_db?sslmode=verify-ca&sslrootcert=/myrootcert
For more details:
$ mzcli --help
Usage: mzcli [OPTIONS] [DBNAME] [USERNAME]
Options:
-h, --host TEXT Host address of the postgres database.
-p, --port INTEGER Port number at which the postgres instance is
listening.
-U, --username TEXT Username to connect to the postgres database.
-u, --user TEXT Username to connect to the postgres database.
-W, --password Force password prompt.
-w, --no-password Never prompt for password.
--single-connection Do not use a separate connection for completions.
-v, --version Version of mzcli.
-d, --dbname TEXT database name to connect to.
--mzclirc FILE Location of mzclirc file.
-D, --dsn TEXT Use DSN configured into the [alias_dsn] section
of mzclirc file.
--list-dsn list of DSN configured into the [alias_dsn]
section of mzclirc file.
--row-limit INTEGER Set threshold for row limit prompt. Use 0 to
disable prompt.
--less-chatty Skip intro on startup and goodbye on exit.
--prompt TEXT Prompt format (Default: "\u@\h:\d> ").
--prompt-dsn TEXT Prompt format for connections using DSN aliases
(Default: "\u@\h:\d> ").
-l, --list list available databases, then exit.
--auto-vertical-output Automatically switch to vertical output mode if
the result is wider than the terminal width.
--warn [all|moderate|off] Warn before running a destructive query.
--help Show this message and exit.
mzcli also supports many of the same environment variables as psql for login options (e.g. PGHOST, PGPORT, PGUSER, PGPASSWORD, PGDATABASE).
The SSL-related environment variables are also supported, so if you need to connect a postgres database via ssl connection, you can set set environment like this:
export PGSSLMODE="verify-full"
export PGSSLCERT="/your-path-to-certs/client.crt"
export PGSSLKEY="/your-path-to-keys/client.key"
export PGSSLROOTCERT="/your-path-to-ca/ca.crt"
pgcli -h localhost -p 5432 -U username postgres
Features
The mzcli is written using prompt_toolkit.
Auto-completes as you type for SQL keywords as well as tables and
columns in the database.
Syntax highlighting using Pygments.
Smart-completion (enabled by default) will suggest context-sensitive
completion.
SELECT * FROM <tab> will only show table names.
SELECT * FROM users WHERE <tab> will only show column names.
Primitive support for psql back-slash commands.
Pretty prints tabular data.
Config
A config file is automatically created at ~/.config/mzcli/config at first launch.
See the file itself for a description of all available options.
Contributions:
While we are not mzcli, the following documentation expresses our sentiments
and still correctly represents the development workflow.
If you're interested in contributing to this project, first of all I would like
to extend my heartfelt gratitude. I've written a small doc to describe how to
get this running in a development setup.
https://github.com/dbcli/mzcli/blob/master/DEVELOP.rst
Please feel free to file an issue if you need help, or jump in our community
slack.