A dynamic SQL query builder for Rust that supports MySQL, PostgreSQL, and SQLite with a unified API.
SeaQuery is a dynamic SQL query builder for Rust that allows developers to construct SQL queries programmatically using an abstract syntax tree (AST). It solves the problem of building complex, runtime-generated SQL queries with proper parameter binding and cross-database compatibility. The library provides a unified API for MySQL, PostgreSQL, and SQLite, making it easier to write database-agnostic code.
Rust developers working with SQL databases who need to build dynamic queries, such as those constructing filters based on user input or maintaining cross-database applications. It's particularly useful for developers using or building ORMs like SeaORM.
Developers choose SeaQuery for its type-safe, ergonomic API that eliminates SQL injection risks and manual parameter binding. Its unique selling point is the ability to write a single query logic that works across multiple database backends while providing advanced features like complex condition builders and schema manipulation.
🔱 A dynamic SQL query builder for MySQL, Postgres and SQLite
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Enables runtime query building with a fluent interface, using methods like `apply_if` to conditionally add clauses without manual string concatenation, as shown in the README's dynamic query example.
Automatically handles parameter sequencing to prevent SQL injection and 'off-by-one' errors, demonstrated in examples where values are injected with proper $N placeholders.
Provides a unified API for MySQL, PostgreSQL, and SQLite, allowing single-source query logic with backend-specific adjustments, evident in the ON CONFLICT clause examples.
Supports arbitrarily nested WHERE/HAVING conditions using `Cond::any()` and `Cond::all()`, respecting operator precedence without cluttering parentheses, as illustrated in the condition builder section.
MS SQL Server support is only available under SeaORM X, a paid plan, which restricts free usage and may require additional cost for teams relying on that database.
Relies on numerous optional feature flags for type support and backends (e.g., `with-chrono`, `backend-postgres`), increasing setup complexity and potential dependency bloat.
For highly complex queries, the README admits needing the `raw_query!` macro as an escape hatch, indicating the builder doesn't cover all edge cases, requiring fallback to raw SQL.