coder-rust-sqlx-queries

<skill_overview> Write safe, validated, and efficient SQLx queries

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "coder-rust-sqlx-queries" with this command: npx skills add ozerohax/assistagents/ozerohax-assistagents-coder-rust-sqlx-queries

<skill_overview> Write safe, validated, and efficient SQLx queries

Writing SQL queries with SQLx Using compile-time query macros Optimizing database access patterns Working with transactions

SQLx GitHub

</skill_overview> <query_rules>

Use query! or query_as! for compile-time validation

Always bind parameters, never concatenate user input

Use fetch_one, fetch_optional, fetch_all appropriately

let rec = sqlx::query!("SELECT id FROM users WHERE email = $1", email) .fetch_optional(&pool) .await?;

</query_rules> <compile_time_checks>

Ensure DATABASE_URL is available at build time Use sqlx prepare and SQLX_OFFLINE for offline builds

</compile_time_checks>

Wrap multi-step changes in a transaction Pass &mut Transaction to query calls

let mut tx = pool.begin().await?; sqlx::query!("DELETE FROM items WHERE id = $1", id) .execute(&mut tx) .await?; tx.commit().await?;

Batch queries instead of querying in loops Prefer streaming fetch for large result sets

<anti_patterns> Never build SQL via string concatenation Do not create a new pool per request Avoid running queries inside loops </anti_patterns>

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

coder-csharp-aspnetcore-api

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

coder-rust-async-concurrency

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

coder-rust-axum-api

No summary provided by upstream source.

Repository SourceNeeds Review