rust-database-guidelines

Implement Rust database access patterns with SQLx and Diesel.

Updated Dec 13, 2025
One-click install
npx skills add https://github.com/imehr/vet --skill rust-database-guidelines
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust-database-guidelines
Source: https://github.com/imehr/vet/tree/main/.claude/skills/rust-database-guidelines
Command: npx skills add https://github.com/imehr/vet --skill rust-database-guidelines

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

The skill provides proven patterns for building reliable database layers in Rust, offering guidance for connecting, querying, and migrating data with SQLx and Diesel.

Core Features & Use Cases

  • Patterns for Connection Pool, Model Definitions, Repository, Transactions, Complex Queries, and Migrations.
  • Real-world scenarios include building a Rust web service with safe data access, transactional operations, and maintainable migrations.

Quick Start

Use the rust-database-guidelines skill to scaffold a Rust project with SQLx or Diesel, configure a Postgres connection pool, and implement a minimal UserRepository with a find_by_id query.

Frequently Asked Questions about rust-database-guidelines

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

FAQPage Schema
How do I set up a Rust database connection pool with SQLx or Diesel?

To set up a Rust database connection pool, you configure pool parameters in your Rust service and use SQLx or Diesel to manage connections to PostgreSQL, enabling safe and fast concurrent data access.

How do I implement the repository pattern for database access in Rust?

The repository pattern in Rust is implemented by creating structs that encapsulate database queries, using SQLx or Diesel to handle model definitions and complex queries while keeping data access logic separate from business logic.

Can I use SQLx for compile-time checked queries in a Rust web service?

Yes, SQLx supports compile-time checked queries in Rust web services, verifying SQL syntax against your PostgreSQL schema at build time to prevent runtime database errors before deployment.

What is the best way to handle database migrations in a Rust project?

Database migrations in a Rust project are handled by applying versioned migration scripts through SQLx or Diesel, ensuring your PostgreSQL schema changes are tracked, maintainable, and applied consistently.

How do I manage database transactions in Rust using an ORM?

Database transactions in Rust are managed by wrapping multiple repository operations in a transaction block using SQLx or Diesel, ensuring atomic execution so that complex queries either fully succeed or roll back.

SQLx vs Diesel: which Rust ORM should I use for async data access?

SQLx provides async data access with compile-time checks, making it ideal for async Rust services, while Diesel offers a mature sync ORM approach; choose based on whether your PostgreSQL service requires async or sync execution.