Rc sqlx
Implements and reviews SQLx 0.8+ with PostgreSQL in Rust — PgPool, query/query_as, bind parameters, transactions, migrations, compile-time macros, database tests. Use when writing or changing SQLx/Postgres access from Rust. Do not use for Axum routing alone (rc-axum), SvelteKit (rc-sveltekit), Rust idioms (rc-rust), or non-Rust ORMs.From its SKILL.md
npx -y skills add rodolfochicone/rc-project --skill rc-sqlxAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 21 stars21 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
2.7 KB, as published. Nobody here has run it
SQLx 0.8 + PostgreSQL
Async SQL for Rust without a heavy ORM. Target: sqlx 0.8.x, PostgreSQL 16 (compatible with 14+). Complements rc-sql (general SQL design) and rc-axum (HTTP layer).
Core workflow
- Schema first — migrations under version control; no ad-hoc prod DDL from app code without a migration path.
- Pool — one
PgPoolin app state; tunemax_connectionsto VPS/DB limits. - Queries — always bind parameters (
$1,$2); neverformat!user input into SQL. - Mapping —
query_as/FromRowor compile-timequery_as!whenDATABASE_URLis available at build. - Transactions — multi-step writes use
pool.begin()→ commit/rollback. - Security — least-privilege DB role; secrets only in env. Read
references/security.md. - Test —
sqlx::testor isolated DB. Readreferences/testing.md.
Reference guide
| Topic | File | Load when |
|---|---|---|
| Pool, query_as, transactions, macros | references/guide.md | Implementing queries |
| Injection, roles, secrets | references/security.md | Reviewing data access |
| Migrations (sqlx-cli / embed) | references/migrations.md | Schema changes |
| Integration tests | references/testing.md | DB tests |
Must do
- Use bound parameters for all dynamic values (Postgres
$n). - Prefer
query_as::<_, T>orquery_as!into serde/FromRow structs. - Set pool size consciously (small VPS: start with 5–10).
- Run migrations in deploy pipeline before app start (or controlled startup migrate).
- Map
sqlx::Errorto domain/HTTP errors without leaking SQL internals to clients.
Must not do
- Share one long-lived transaction across HTTP requests.
- Use the superuser role for the app in production.
- Commit migrations that are not reversible or documented when data loss is possible.
- Ignore offline mode needs for CI (
SQLX_OFFLINE=true+.sqlxdata) if using macros without a live DB.
Output template
- Migration SQL (up, and down if required)
- Rust types (
FromRow/ domain models) - Query functions (pool/tx receiver)
- Error mapping
- Tests +
cargo test/ sqlx prepare notes
Related skills
rc-axum— wire pool intoStaterc-sql— indexes, EXPLAIN, schema design depthrc-observability— slow query / pool metrics