Generate type-checked Rust
from your PostgreSQL
Cornucopia is a tool powered by rust-postgres designed to generate type-checked Rust interfaces from your PostgreSQL queries.
Features
SQL-first
Your SQL is the only source of truth. No intricate ORM.
Custom user types
Cornucopia supports composites, enums, domains and one-dimensional arrays out of the box.
Powerful query validation
Catch errors before runtime, with powerful (and pretty) diagnostics.
Granular type nullity control
Easily customize what columns should be nullable.
Row mapping
Map your query rows using our ergonomic non-allocating API.
Sync and async
Cornucopia can generate both sync and async Rust.
Available as a library and a CLI
Cornucopia is flexible and tries to accomodate all your workflows seemlessly.
Competitive performance
Cornucopia generates your code quickly, and the generated code's performance is as close to native `rust-postgres` as we can make it.
Designed to facilitate PostgreSQL
for your Rust projects.
- Cornucopia aims to get out of your way, transpiling your PostgreSQL queries to Rust on demand.
- Each query is prepared against your schema, ensuring that the query statements are valid and type-checked.
- Ergonomic while being free of heavy macros or complex generics.