Best Database CLI Clients

Compare usql, pgcli, mycli, harlequin and lazysql for querying Postgres, MySQL and SQLite from the terminal, with notes on dblab.

Updated

short verdict

Pick usql if you work across several database engines and want one psql-style client. Pick pgcli for PostgreSQL or mycli for MySQL if you mostly type queries and want context-aware completion. Pick harlequin, lazysql or dblab if you want a full-screen TUI with a results pane and schema browser.

Database CLI clients fall into two groups. Line-oriented clients such as pgcli, mycli and usql replace psql or mysql with completion and highlighting at a prompt. Full-screen TUIs such as harlequin, lazysql and dblab add a schema browser, tabs or a query editor with a results grid. The other differences are engine coverage (one database versus dozens) and runtime: Python packages versus single Go binaries.

this page is for

  • Developers who query PostgreSQL, MySQL and SQLite from one terminal
  • psql or mysql users who want completion and syntax highlighting
  • People who prefer a TUI with schema browsing over a prompt
  • Users who reach databases through SSH tunnels or bastions
#1

usql

★ 10.2kGo
details

One psql-style client that connects to PostgreSQL, MySQL, SQLite3, SQL Server, Oracle and more, so it is the best default across engines.

best for

  • Working with several database engines
  • Existing psql users
  • Copying data between databases

strengths

  • Supports over 30 drivers through Go's SQL interface
  • Replicates psql features: variables, backticks, backslash commands
  • Copies data from one database to another
  • Build tags let you compile only the drivers you need

weaknesses

  • Completion is described as context-based, with no engine-specific smart suggestions documented
  • No schema browser or results grid; it stays a prompt-based client
  • Custom driver sets require building with Go build tags
#2

pgcli

★ 13.4kPython
details

Best choice for PostgreSQL only, with completion that narrows to tables after FROM and columns after WHERE.

best for

  • PostgreSQL-only work
  • psql users who want completion
  • IPython users

strengths

  • Context-sensitive completion for keywords, tables and columns
  • Supports many psql backslash commands and PGHOST/PGPORT variables
  • Automatic vertical output for wide results
  • pgcli.magic extension opens a session inside IPython

weaknesses

  • PostgreSQL only; no MySQL or SQLite support
  • Python package, so it needs pip or a system package
  • No schema browser or multi-pane interface
#3

mycli

★ 12.0kPython
details

The pgcli equivalent for MySQL, adding fzf history search and saved queries with positional parameters.

best for

  • MySQL-only work
  • Saving and reusing favorite queries
  • Logging output to files or pipes

strengths

  • Completion for keywords, tables, views and columns
  • Fuzzy history search with fzf
  • Saved queries via \fs and run with \f; redirection with $>, $>> and $|
  • Config in ~/.myclirc with custom key bindings

weaknesses

  • MySQL only
  • Requires Python 3.10+
  • Windows support is experimental, through WSL or native install
#4

harlequin

★ 6.5kPython
details

A terminal SQL IDE with a data catalog, editor and results pane, covering DuckDB and SQLite out of the box plus adapters for Postgres and MySQL.

best for

  • DuckDB and SQLite analysis
  • Browsing a catalog while writing queries
  • Django projects

strengths

  • Adapter plug-ins for PostgreSQL, MySQL/MariaDB, S3 and ODBC
  • Built-in DuckDB and SQLite support
  • Configurable themes, key bindings and connection profiles
  • Runs on Linux, macOS and Windows; django-harlequin reuses Django's database settings

weaknesses

  • Each non-default database needs a separate adapter package
  • Requires Python 3.9 or above
  • Full-screen interface is heavier than a prompt for one-off queries
#5

lazysql

★ 4.4kGo
details

A Go TUI with tabs, Vim keybindings and SSH tunneling, suited to browsing and editing tables on remote MySQL, PostgreSQL, SQLite or MSSQL.

best for

  • Remote databases behind bastions
  • Vim users
  • Browsing and editing rows

strengths

  • Multiple connections in tabs, with a read-only mode
  • SSH tunneling and pre-connection commands for port-forwarding
  • Built-in SQL editor on Ctrl+E, WHERE filtering, CSV export
  • TOML configuration and saved connections

weaknesses

  • Covers MySQL, PostgreSQL, SQLite and MSSQL only, not Oracle
  • CRUD is described as basic
  • No documented completion or syntax highlighting in the editor

How to choose

Match the tool to the engines you use and whether you want a prompt or a full-screen interface.

  • Multiple engines from one client: usql, which covers over 30 drivers with psql-style commands.
  • PostgreSQL-only completion: pgcli, with context-aware suggestions and IPython integration.
  • MySQL-only completion and saved queries: mycli, with fzf history search and \fs aliases.
  • Schema browser plus editor: harlequin, which has a data catalog and DuckDB and SQLite built in.
  • Remote databases through SSH or Kubernetes port-forwarding: lazysql, with tunneling and pre-connection commands.

When not to use these

  • You need a graphical schema designer or ER diagrams, which these terminal tools do not provide.
  • You only run scripted queries in CI, where plain psql or mysql is enough and needs no interactive features.

Also worth a look

  • dblabGo TUI with a Vim-style query editor, SSH tunneling and Unix sockets; covers PostgreSQL, MySQL, SQLite3, Oracle and SQL Server.

FAQ

What is the best terminal client for both Postgres and MySQL?
usql handles both through one psql-style interface, along with SQLite3, SQL Server and Oracle. Harlequin also covers both, but Postgres and MySQL each need a separate adapter package.
Is pgcli a replacement for psql?
It adds auto-completion and syntax highlighting and supports many psql backslash commands. It reads PGHOST and PGPORT and is configured through ~/.config/pgcli/config.
Which client works with SQLite?
usql, harlequin, lazysql and dblab all list SQLite support. pgcli is PostgreSQL only and mycli is MySQL only.
Which tools support SSH tunneling?
lazysql and dblab both support SSH tunneling for remote databases. lazysql also runs pre-connection commands for port-forwarding.