rc-sqlx

Implements and reviews SQLx 0.8 PostgreSQL data access in Rust applications.

19|1|Updated Jun 27, 2026
One-click install
npx skills add https://github.com/rodolfochicone/rc-project --skill rc-sqlx-rodolfochicone
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: rc-sqlx
Source: https://github.com/rodolfochicone/rc-project/tree/main/skills/stacks/rc-sqlx
Command: npx skills add https://github.com/rodolfochicone/rc-project --skill rc-sqlx-rodolfochicone

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing safe, correct async database access in Rust with SQLx and PostgreSQL requires juggling pools, bind parameters, transactions, migrations, and compile-time macros, and mistakes lead to SQL injection, connection exhaustion, or broken deploys. ## Core Features & Use Cases - Query Implementation: Guides PgPool setup, query/query_as with bound parameters, FromRow mapping, and compile-time query_as! macros with offline mode. - Migrations & Transactions: Covers sqlx-cli and embedded migrators, forward-only migration rules, and multi-step writes with pool.begin() commit/rollback. - Security & Testing Review: Enforces least-privilege roles, secrets handling, injection prevention, and integration tests with sqlx::test against real Postgres. - Use Case: When adding a new metrics table to a Rust/Axum service, use this Skill to write the migration, the FromRow struct, bound query functions, error mapping, and Docker-backed integration tests. ## Quick Start Use the rc-sqlx skill to implement a new PostgreSQL table with migration, typed queries, and tests in my Rust project.

Frequently Asked Questions about rc-sqlx

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

FAQPage Schema
How do I use SQLx with PostgreSQL in Rust?▼

Create one PgPool with PgPoolOptions, clone it into application state, and run queries with sqlx::query or query_as using $1, $2 bind placeholders. Map rows into structs deriving FromRow, and use pool.begin() for multi-step transactions.

How do I prevent SQL injection in SQLx queries?▼

Pass every dynamic value through .bind() or macro arguments, never with format! or string concatenation. For dynamic identifiers like sort columns, use a Rust allowlist that maps input to fixed column names.

Does SQLx support compile-time checked queries?▼

Yes, the query! and query_as! macros validate SQL against a live database at compile time when DATABASE_URL is set. For CI without a database, run cargo sqlx prepare and build with SQLX_OFFLINE=true using the .sqlx data.

How do I run SQLx migrations in production?▼

Prefer running sqlx migrate run in the deploy pipeline before switching traffic, or use the embedded sqlx::migrate! macro with a single migrator instance. Keep migrations forward-only and never hand-edit already applied files.

How do I test SQLx repository code?▼

Use the #[sqlx::test] attribute or a Docker Postgres container with migrations applied, testing against a real database rather than mocking the pool. Assert on row content, constraint violations, and transaction rollback behavior.

When should I not use SQLx for Rust database access?▼

SQLx is not a full ORM, so if you need automatic relationship loading, schema generation from models, or a query builder DSL, a different tool fits better. This Skill also does not cover Axum routing or general SQL schema design, which belong to rc-axum and rc-sql.