For checked SQL queries for Rust, the first results are launchbadge/sqlx (SQLx is a Rust library that uses procedural macros to validate SQL syntax and parameter types at compile time against a live database, providing type-safe query results and supporting multiple databases, connection pooling, and migrations—exactly matching the required features), diesel-rs/diesel and kysely-org/kysely (This is a TypeScript SQL query builder with compile-time type safety and schema compliance, but the visitor specifically wants a Rust library, so it is not usable in Rust projects). sqlc-dev/sqlc and prismagraphql/prisma round out the shortlist. Compare the match explanations and check the project documentation against your requirements.
Libraries and frameworks that provide type-safe SQL query validation during the Rust compilation process.
This toolkit provides an asynchronous interface for interacting with relational databases, offering a unified driver-agnostic layer for managing connection pools and executing transactions. It is designed to integrate with asynchronous runtimes, enabling non-blocking database operations while maintaining secure, encrypted communication between the application and the database server. The project distinguishes itself through its compile-time validation capabilities, which use procedural macros to inspect SQL syntax and parameter types against a live database schema during the build process. Th
SQLx is a Rust library that uses procedural macros to validate SQL syntax and parameter types at compile time against a live database, providing type-safe query results and supporting multiple databases, connection pooling, and migrations—exactly matching the required features.
This project is a type-safe database toolkit and object-relational mapper designed to enforce structural consistency between database schemas and application code. By leveraging compile-time validation, it ensures that SQL queries and data structures remain synchronized, preventing common errors before the application executes. It provides a comprehensive framework for relational data modeling, allowing developers to define table associations and map database results directly into strongly-typed language objects. The library distinguishes itself through its focus on compile-time safety and au
Diesel is the Rust ORM and query builder that enforces compile-time schema-aware SQL validation, type-safe query results via a macro-based DSL, and includes support for multiple databases, connection pooling, and migrations—exactly the library you need for compile-time checked SQL.
Kysely is a TypeScript SQL query builder that provides a type-safe interface for constructing and executing database queries. It functions as a database layer that ensures schema compliance and prevents runtime errors by using a fluent interface and a programmable way to build complex SQL statements. The project features a type-safe database layer capable of inferring return types and aliases from SQL selections and joins. It also includes a SQL migration manager to track and apply schema changes across different environments to keep database versions synchronized. The toolkit covers relatio
This is a TypeScript SQL query builder with compile-time type safety and schema compliance, but the visitor specifically wants a Rust library, so it is not usable in Rust projects.
sqlc is a code generation tool that compiles raw SQL queries into type-safe application code. By analyzing SQL statements against database schema definitions during the build process, it eliminates the need for manual data mapping and prevents runtime type errors. The project functions as a schema-aware generator that translates database column types into native language primitives. It distinguishes itself through a modular, plugin-based architecture that allows for the extension of the generation pipeline to support diverse programming languages and custom frameworks beyond its default capab
sqlc is a code-generation tool that validates SQL queries at compile time and generates type-safe code for multiple languages, but it is a CLI tool written in Go, not a Rust library you can import and use directly.
Prisma is a type-safe database object-relational mapper that uses a declarative schema to map data models to relational and document databases. It provides a unified toolkit for data access, combining a database driver with tools for schema management and record manipulation. The project features a multi-database driver that standardizes interactions across PostgreSQL, MySQL, and MongoDB. It includes a system for tracking and applying structural schema migrations across different environments and a graphical user interface for browsing and editing database records. The system ensures data in
Prisma is a type-safe ORM with schema-based data access, but it is not a Rust library focused on compile-time SQL query validation; it is a broader toolkit across multiple languages, so it only partially overlaps with your search.
SQLite.swift is a type-safe Swift wrapper and object-relational mapping layer that provides a bridge for interacting with SQLite databases. It functions as a database driver that allows for embedded database management and local data persistence within Swift applications. The project distinguishes itself through a type-safe expression builder that verifies SQL statement syntax and intent at compile time. It includes specialized support for high-performance text matching via full-text search integration and provides mechanisms for securing sensitive data through database encryption. The libra
This is a Swift library that validates SQL queries at compile time with a type-safe builder, but the search specifically asks for a Rust library, so the language mismatch places it as a related but not direct answer.
Prisma is a database toolkit that provides a unified access layer for interacting with relational and document databases. It centers on a declarative schema modeling approach, where developers define their data structures in a human-readable language. This schema serves as the single source of truth, from which the toolkit automatically generates type-safe database clients that provide compile-time validation and editor autocomplete for all data operations. The project distinguishes itself through a high-performance, Rust-based query engine that handles query planning and connection pooling o
Prisma is a database ORM for TypeScript/JavaScript with a Rust-based engine that generates type-safe clients, but it is a full ORM toolkit in that language ecosystem, not a Rust library for compile-time validated raw SQL queries — the language and focus differ from what you are looking for.
Sea-ORM is an asynchronous SQL object-relational mapper and database toolkit for mapping relational tables to strongly typed objects. It provides a relational database mapper for performing CRUD operations across MySQL, PostgreSQL, and SQLite, and includes a programmatic dynamic query builder for constructing complex SQL statements. The project distinguishes itself by providing a GraphQL schema generator that transforms database entities into typed schemas with built-in pagination and filters. It also features a dedicated database migration tool for defining and applying versioned schema chan
Sea-ORM is a full-featured ORM and migration toolkit for Rust, supporting multiple databases and connection pooling, but its query builder is programmatic and runtime-based, not a macro that validates SQL at compile time—so it does not provide the compile-time SQL syntax checking your search is focused on.
Drift is a type-safe SQL persistence library and relational mapper that provides a structured way to map database tables to classes and execute SQL queries with build-time validation. It functions as a type-safe query builder and a wrapper for SQLite and PostgreSQL, eliminating manual result set parsing by binding query outputs to native objects. The project distinguishes itself through a build-time code generation system that produces type-safe APIs and validates raw SQL statements against database versions before execution. It features reactive query streaming, which transforms SQL queries
Drift provides compile-time SQL validation and type-safe queries, but it is a Dart/Flutter library, not a Rust library—your search specifically calls for a Rust-based compile-time checked SQL query library, so this candidate is in the wrong language ecosystem.
ihp is a type-safe web framework and full-stack application orchestrator designed for PostgreSQL. It functions as a server-side rendering framework and a type-safe ORM that automatically generates record types from SQL schemas to ensure compile-time query validation. The platform distinguishes itself by verifying routing, database queries, and templates at compile time to prevent runtime crashes. It implements real-time web interfaces using WebSockets for instant data synchronization and employs server-driven hypermedia for partial DOM patching. The framework covers a broad range of integrat
IHP is a Haskell web framework with compile-time SQL validation, but it's not a Rust library — you need a Rust-focused tool like sqlx for compile-time checked queries.
| Repository | Stars | Language | License | Last push |
|---|---|---|---|---|
| launchbadge/sqlx | 16.6K | Rust | apache-2.0 | |
| diesel-rs/diesel | 14K | Rust | apache-2.0 | |
| kysely-org/kysely |
| 14K |
| TypeScript |
| MIT |
| sqlc-dev/sqlc | 17.9K | Go | MIT |
| prismagraphql/prisma | 16.4K | Scala | Apache-2.0 |
| stephencelis/sqlite.swift | 10.2K | Swift | MIT |
| prisma/prisma | 46.4K | TypeScript | Apache-2.0 |
| seaql/sea-orm | 9.4K | Rust | apache-2.0 |
| simolus3/drift | 3.2K | Dart | MIT |
| digitallyinduced/ihp | 5.3K | Haskell | MIT |