rust-sqlx

Implement PostgreSQL data access with sqlx compile-time checks and offline builds.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/ohaddahan/claude-extras --skill rust-sqlx
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust-sqlx
Source: https://github.com/ohaddahan/claude-extras/tree/main/skills/rust-sqlx-skill
Command: npx skills add https://github.com/ohaddahan/claude-extras --skill rust-sqlx

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Rust developers building PostgreSQL-backed applications often struggle with safe, maintainable data access patterns, migrations, and reliable builds in CI. This Skill provides a structured approach for using sqlx to combine compile-time checks, runtime queries, and offline preparation.

Core Features & Use Cases

  • Compile-time queries: Use the query! and query_as! macros to catch schema issues at compile time and ensure strong type safety.
  • Runtime queries & FromRow: Flexible runtime querying for dynamic schemas and direct mapping into Rust structs.
  • Migrations with sqlx-cli: Manage reversible migrations with a clear workflow and repeatable steps.
  • Offline mode with prepare: Precompute query metadata to enable builds without live DB during CI or embedded deployments.

Quick Start

Install Rust toolchain, configure DATABASE_URL to a PostgreSQL database, run cargo check, then cargo sqlx prepare to cache queries for offline builds.

Frequently Asked Questions about rust-sqlx

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use sqlx compile-time queries to check PostgreSQL schemas in Rust?

Sqlx compile-time queries use the query! and query_as! macros to validate SQL against your PostgreSQL schema at build time, catching database errors early. This ensures strong type safety before your Rust application ever runs.

How do I run sqlx migrations for a Postgres database using the command line?

Sqlx migrations are managed using the sqlx-cli tool to apply reversible database schema changes. This provides a clear, repeatable workflow for creating and running migration scripts directly against your PostgreSQL database.

How do I build a Rust project with sqlx in CI without a live database connection?

Offline sqlx builds use the cargo sqlx prepare command to precompute and cache query metadata. This allows your Rust CI pipelines to compile database code without needing a live PostgreSQL connection.

When should I use runtime queries instead of compile-time macros in sqlx?

Runtime sqlx queries are necessary when dealing with dynamic schemas or SQL strings generated at execution time. They use the FromRow trait to map results directly into Rust structs without compile-time schema validation.

Do I need a running PostgreSQL database to develop a Rust application with sqlx?

A PostgreSQL database is required during initial development to validate compile-time queries and generate offline metadata. Once prepared with cargo sqlx prepare, subsequent builds and CI runs can operate entirely offline.