sqlx
Rust SQL toolkit with compile-time checks
TLDR
Create database
SYNOPSIS
sqlx command [options]
DESCRIPTION
sqlx is a command-line tool for the SQLx Rust SQL toolkit that provides database migration management and compile-time query verification. It supports PostgreSQL, MySQL, MariaDB, and SQLite.
The migration system creates versioned SQL scripts that track schema changes, with commands to create, run, and revert migrations. The prepare command caches query metadata to a JSON file, enabling compile-time type checking of SQL queries in Rust code without requiring a live database connection during builds.
A DATABASE_URL environment variable or .env file must specify the database connection string for all operations.
PARAMETERS
database
Database operations.migrate
Migration commands.prepare
Prepare for offline.--database-url URL
Connection string.add
Add migration.run
Run migrations.
CONFIGURATION
DATABASE_URL
Environment variable specifying the database connection string (e.g., postgres://user:pass@host/db, sqlite:data.db)..env
Project-level file where DATABASE_URL can be defined; automatically loaded by sqlx commands.
CAVEATS
Rust development tool. DATABASE_URL required. Compile-time checks.
HISTORY
sqlx is a Rust SQL toolkit providing compile-time checked queries and database migrations.
