sqlx-query

Implement compile-time verified SQLx queries with macros and dynamic SQL safety.

Updated May 26, 2026
One-click install
npx skills add https://github.com/adelabdelgawad/rust-fullstack-agents --skill sqlx-query
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: sqlx-query
Source: https://github.com/adelabdelgawad/rust-fullstack-agents/tree/main/plugins/rusty/skills/sqlx-query
Command: npx skills add https://github.com/adelabdelgawad/rust-fullstack-agents --skill sqlx-query

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Compile-time verification and safe dynamic SQL for SQLx in Rust, reducing runtime errors and security risks.

Core Features & Use Cases

  • Macro selection for query!, query_as!, query_scalar!, and query_file!
  • AssertSqlSafe dynamic SQL handling, executor-generic patterns, and transaction/savepoint support
  • End-to-end patterns for fetch_one, fetch_optional, fetch_all, and FromRow usage across pools, connections, and transactions.

Quick Start

Begin using sqlx-query by enabling a few macros and start writing compile-time-verified SQLx queries in your Rust code.

Frequently Asked Questions about sqlx-query

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

FAQPage Schema
How do I verify SQLx queries at compile time in Rust?▼

Compile-time verification for SQLx queries in Rust is achieved by using query macros like query! and query_as!. This validates SQL syntax against your database schema during the build process, reducing runtime errors.

Do I need a DATABASE_URL to build Rust projects with SQLx macros?▼

You need a live DATABASE_URL at build time or a .sqlx offline cache to use SQLx macros. The offline cache enables compile-time query verification without an active database connection during the build.

How can I write safe dynamic SQL with SQLx in Rust?▼

Safe dynamic SQL with SQLx in Rust is handled using the AssertSqlSafe pattern. This allows you to construct runtime SQL fragments securely while maintaining protection against injection risks.

Can I use SQLx transactions and savepoints with Rust query macros?▼

Yes, SQLx transactions and savepoints work with Rust query macros using executor-generic patterns. This allows you to execute fetch_one, fetch_all, and fetch_optional operations across pools and transactions.

What is the difference between query_as! and query_scalar! in SQLx?▼

In SQLx, query_as! maps query results to custom structs using FromRow, while query_scalar! maps results to single primitive values. Macro selection depends on your specific query return type requirements.

Why is my SQLx macro failing to verify a dynamic SQL query?▼

SQLx macros fail to verify dynamic SQL queries because compile-time verification requires static strings. You must use the AssertSqlSafe pattern for constructing runtime SQL fragments to bypass macro limitations.