// the find
SeaQL/sea-query
🔱 A dynamic SQL query builder for MySQL, Postgres and SQLite
SeaQuery is a Rust SQL query builder that compiles queries to MySQL, Postgres, and SQLite from a single AST. It sits below SeaORM in the SeaQL stack and is the right tool when you want type-safe, parameterized SQL without a full ORM. The 1.0 release added a `raw_query!` macro with named parameters and vector expansion that makes the escape hatch actually usable.
The parameter binding story is genuinely good — `$N` sequencing is handled automatically, even when mixing builder expressions with `Expr::cust_with_values`, which is where most query builders fall apart. The `Iden` derive macro plus `enum_def` means your schema is defined once and the compiler catches column name typos at build time, not runtime. Cross-database `ON CONFLICT` handling (MySQL's `ON DUPLICATE KEY` vs Postgres/SQLite's `ON CONFLICT DO UPDATE`) is correctly abstracted without leaking backend specifics. The `postgres-vector` feature flag means you can express pgvector operations without dropping to raw SQL.
The `Iden` enum pattern forces you to maintain a parallel type hierarchy that mirrors your schema — it works but adds ceremony that Diesel's codegen or sqlx's `query!` macro avoid entirely. Schema DDL support is thin: no `CREATE INDEX CONCURRENTLY`, no partial indexes, no expressions in index definitions — you'll hit raw SQL for anything beyond basic indexes. The `raw_query!` macro syntax (`{..d}`, `{..(values.0:1),}`) is non-obvious enough that you'll re-read the docs every time. No async story of its own — it's purely a string/value builder, so async execution depends entirely on which driver crate you wire up, and the integration crates (sea-query-sqlx, sea-query-rusqlite) are versioned separately with their own compatibility matrix to manage.