Skip to the content
Know your tech before you buy it. Makers: get listed from $49/mo

sqlx-cli

github.com

  • Free plan
  • Windows
  • macOS
  • Linux
7.9 Club score Visit github.com

What sqlx-cli is

sqlx-cli is SQLx’s command-line utility for database management, migrations, and preparing query macros for offline builds. It can create or drop the database specified by `DATABASE_URL`, and create, run, inspect, or revert migrations, including paired up and down scripts. The `cargo sqlx prepare` command saves query metadata in a `.sqlx` directory; when that directory is checked into version control, builds can proceed without an active database connection. For continuous integration, `cargo sqlx prepare --check` returns a nonzero status when saved metadata is outdated. In a workspace with multiple crates using query macros, `cargo sqlx prepare --workspace` creates one `.sqlx` directory at the workspace root. Commands take a database URL from `--database-url`, the `DATABASE_URL` environment variable, or a `.env` file in the current directory. SQLx lists PostgreSQL, MySQL, MariaDB, and SQLite among supported databases. Installation is documented through `cargo install sqlx-cli`, with options for database drivers and TLS backends. The project is free and available under Apache-2.0 or MIT licensing. MSSQL support was removed pending a full rewrite of the driver.

Who it suits

It suits Rust developers using SQLx who need database and migration commands or offline query-macro builds. Teams can use its metadata check in continuous integration.

Good to know, and what to watch

  • Creates, runs, inspects, and reverts migrations.
  • Supports offline builds with checked-in metadata.
  • Includes a metadata freshness check for CI.
  • Supports PostgreSQL, MySQL, MariaDB, and SQLite.
  • Available under Apache-2.0 or MIT licensing.
  • MSSQL support was removed.
  • Commands require a configured database URL.
  • MySQL RSA authentication may require an installation feature.

sqlx-cli

Free

Open source

The verdict

sqlx-cli covers database setup, migration workflows, and query-metadata preparation for SQLx projects. Its offline build and CI checks are useful, but MSSQL is not supported.

What the maker publishes

CI check
`cargo sqlx prepare --check` exits with a nonzero status when cached metadata is outdated and is described as intended for continuous integration. source
CI use
`cargo sqlx prepare --check` exits with a nonzero status if the saved query metadata is out of date, and the README describes it as intended for Continuous Integration. source
Configuration
Commands require a database URL supplied through `--database-url`, the `DATABASE_URL` environment variable, or a `.env` file in the current working directory. source
Connection configuration
Commands require a database URL supplied with `--database-url` or through `DATABASE_URL` in the environment or a `.env` file. source
Database commands
The CLI can create and drop the database specified by `DATABASE_URL`. source
Database management
The CLI can create and drop the database specified by `DATABASE_URL`. source
Database support
Its default installation supports the databases supported by SQLx; installation options include PostgreSQL-only and SQLite-specific configurations. source
Installation
The README documents installation through `cargo install sqlx-cli` and shows feature options for choosing database drivers and TLS backends. source
Installation
The CLI can be installed with `cargo install sqlx-cli`. source
License
The SQLx repository offers the project under either the Apache-2.0 or MIT license, at the user's option. source
License
The SQLx repository lists Apache-2.0 and MIT license files. source
Migrations
It can create, run, inspect, and revert migrations, including paired up and down migration scripts. source
Migrations
It can create migration files, run pending migrations, show migration status, and revert reversible migrations. source
MySQL authentication limit
The `mysql-rsa` feature is needed for non-TLS MySQL or MariaDB connections when the server requires RSA authentication using `caching_sha2_password` or `sha256_password`. source
Notable limitation
The project README says MSSQL support was removed pending a full rewrite of the driver as part of the SQLx Pro initiative. source
Offline builds
`cargo sqlx prepare` saves query metadata to `.sqlx`, allowing builds without an active database connection after that directory is checked into version control. source
Offline mode setting
Setting `SQLX_OFFLINE=true` forces offline builds when a `DATABASE_URL` variable or `.env` file is present. source
Offline query preparation
`cargo sqlx prepare` saves query metadata to `.sqlx`, allowing builds without an active database connection when that metadata is checked into version control. source
Project scope
The SQLx project describes itself as an asynchronous, pure Rust SQL toolkit with compile-time checked queries and support for PostgreSQL, MySQL, and SQLite. source
Purpose
SQLx CLI is SQLx’s command line utility for managing databases and migrations and enabling offline mode for query macros. source
Purpose
SQLx CLI is a command-line utility for managing databases and migrations and enabling offline mode for SQLx query macros. source
Query metadata scope
For workspaces with multiple crates using query macros, `cargo sqlx prepare --workspace` generates a single `.sqlx` directory at the workspace root. source
Security
The project README says SQLx forbids unsafe code unless the SQLite feature is enabled, where SQLite API calls use unsafe code that the maintainers welcome auditing and feedback on. source
Support
The SQLx repository links to its FAQ and Discord community for questions. source

Checked against the maker's pages on 11 Oct 2026.