rc-sqlx

Solid

Implements and reviews SQLx 0.8+ with PostgreSQL in Rust — PgPool, query/query_as, bind parameters, transactions, migrations, compile-time query macros, and database tests. Use when writing or changing database access with SQLx or Postgres from Rust. Do not use for Axum HTTP routing alone (rc-axum), SvelteKit (rc-sveltekit), Rust language idioms — ownership, error types, async patterns (rc-rust) — or non-Rust ORMs.

API & Backend 19 stars 1 forks Updated 2 weeks ago MIT

Install

View on GitHub

Quality Score: 82/100

Stars 20%
43
Recency 20%
90
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# 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 1. **Schema first** — migrations under version control; no ad-hoc prod DDL from app code without a migration path. 2. **Pool** — one `PgPool` in app state; tune `max_connections` to VPS/DB limits. 3. **Queries** — always **bind** parameters (`$1`, `$2`); never `format!` user input into SQL. 4. **Mapping** — `query_as` / `FromRow` or compile-time `query_as!` when `DATABASE_URL` is available at build. 5. **Transactions** — multi-step writes use `pool.begin()` → commit/rollback. 6. **Security** — least-privilege DB role; secrets only in env. Read `references/security.md`. 7. **Test** — `sqlx::test` or isolated DB. Read `references/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>` or `query_as!` into serde/FromRow structs. - Set pool size consciously (small VPS: start with 5–10). - Run migrations in deploy pipeline ...

Details

Author
rodolfochicone
Repository
rodolfochicone/rc-project
Created
1 months ago
Last Updated
2 weeks ago
Language
JavaScript
License
MIT

Integrates with

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category

Web & Frontend Solid

rc-axum

Implements and reviews Axum 0.8+ APIs in Rust — routing, State, extractors, Tower middleware, typed errors, WebSockets, CORS, timeouts, and production hardening. Use when building or changing Axum backends, handlers, middleware, or real-time WS endpoints. Do not use for SvelteKit/frontends (rc-sveltekit), SQLx/Postgres data layer alone (rc-sqlx), Rust language idioms — ownership, error types, trait design (rc-rust) — or general React/Next work.

19 Updated 2 weeks ago
rodolfochicone
API & Backend Solid

rc-rust

Rust as a language — ownership and lifetimes, error hierarchies with thiserror/anyhow, async with Tokio, trait design, testing, performance, clippy, and rustdoc. Use when writing or reviewing Rust code, deciding between borrowing and cloning, designing an error type, structuring async tasks and channels, or configuring lints and benchmarks. Do not use for Axum HTTP routing and middleware (rc-axum), SQLx/Postgres data access (rc-sqlx), SvelteKit (rc-sveltekit), or non-Rust languages.

19 Updated 2 weeks ago
rodolfochicone
API & Backend Solid

go-database

Use when writing, reviewing, or debugging Go code that talks to a SQL database (PostgreSQL, MySQL, MariaDB, SQLite). Covers library choice (database/sql, sqlx, sqlc, pgx, GORM trade-offs), parameterized queries, context propagation, NULL handling, scanning, transactions and isolation, connection pool tuning, and migration tooling. Apply when adding repository code, refactoring SQL, or auditing for missing rows.Close()/QueryContext.

8 Updated 1 weeks ago
muratmirgun