π SeaORM
Advanced Relations
Model complex relationships 1-1, 1-N, M-N, and even self-referential in a high-level, conceptual way.
Familiar Concepts
Inspired by popular ORMs in the Ruby, Python, and Node.js ecosystem, SeaORM offers a developer experience that feels instantly recognizable.
Feature Rich
SeaORM is a batteries-included ORM with filters, pagination, and nested queries to accelerate building REST, GraphQL, and gRPC APIs.
Production Ready
With 250k+ weekly downloads, SeaORM is production-ready, trusted by startups and enterprises worldwide.
Getting Started
Join our Discord server to chat with others!
Integration examples:
- Actix Example
- Axum Example
- GraphQL Example
- jsonrpsee Example
- Loco Example / Loco REST Starter
- Poem Example
- Rocket Example / Rocket OpenAPI Example
- Salvo Example
- Tonic Example
- Seaography Example (Bakery) / Seaography Example (Sakila)
If you want a simple, clean example that fits in a single file that demonstrates the best of SeaORM, you can try:
Let's have a quick walk through of the unique features of SeaORM.
Expressive Entity format
You don't have to write this by hand! Entity files can be generated from an existing database using sea-orm-cli,
following is generated with --entity-format dense (new in 2.0).
#
#
Smart Entity Loader
The Entity Loader intelligently uses join for 1-1 and data loader for 1-N relations, eliminating the N+1 problem even when performing nested queries.
# use ;
#
ActiveModel: nested persistence made simple
Persist an entire object graph: user, profile (1-1), posts (1-N), and tags (M-N) in a single operation using a fluent builder API. SeaORM automatically determines the dependencies and inserts or deletes objects in the correct order.
# use ;
#
Schema first or Entity first? Your choice
SeaORM provides a powerful migration system that lets you create tables, modify schemas, and seed data with ease.
With SeaORM 2.0, you also get a first-class Entity First Workflow: simply define new entities or add columns to existing ones, and SeaORM will automatically detect the changes and create the new tables, columns, unique keys, and foreign keys.
// SeaORM resolves foreign key dependencies and creates the tables in topological order.
// Requires the `entity-registry` and `schema-sync` feature flags.
db.get_schema_registry("my_crate::entity::*").sync(db);
Ergonomic Raw SQL
Let SeaORM handle 95% of your transactional queries. For the remaining cases that are too complex to express, SeaORM still offers convenient support for writing raw SQL.
# use ;
#
Basics
Select
SeaORM models 1-N and M-N relationships at the Entity level, letting you traverse many-to-many links through a junction table in a single call.
# use ;
#
Nested Select
Partial models prevent overfetching by letting you querying only the fields you need; it also makes writing deeply nested relational queries simple.
# use ;
#
Insert
SeaORM's ActiveModel lets you work directly with Rust data structures and persist them through a simple API. It's easy to insert large batches of rows from different data sources.
# use ;
#
Insert (advanced)
You can take advantage of database specific features to perform upsert and idempotent insert.
# use ;
#
#
Update
ActiveModel avoids race conditions by updating only the fields you've changed, never overwriting untouched columns. You can also craft complex bulk update queries with a fluent query building API.
# use ;
use ;
#
Save
You can perform "insert or update" operation with ActiveModel, making it easy to compose transactional operations.
# use ;
#
Delete
The same ActiveModel API consistent with insert and update.
# use ;
#
Raw SQL Query
The raw_sql! macro is like the format! macro but without the risk of SQL injection.
It supports nested parameter interpolation, array and tuple expansion, and even repeating group,
offering great flexibility in crafting complex queries.
# use ;
#
π§ Seaography: instant GraphQL API
Seaography is a GraphQL framework built for SeaORM. Seaography allows you to build GraphQL resolvers quickly. With just a few commands, you can launch a fullly-featured GraphQL server from SeaORM entities, complete with filter, pagination, relational queries and mutations!
Look at the Seaography Example to learn more.
π₯οΈ SeaORM Pro: Professional Admin Panel
SeaORM Pro is an admin panel solution allowing you to quickly and easily launch an admin panel for your application - frontend development skills not required, but certainly nice to have!
SeaORM Pro has been updated to support the latest features in SeaORM 2.0.
Features:
- Full CRUD
- Built on React + GraphQL
- Built-in GraphQL resolver
- Customize the UI with TOML config
- Role Based Access Control (new in 2.0)
Read the Getting Started guide to learn more.

SQL Server Support
SQL Server for SeaORM offers the same SeaORM API for MSSQL. We ported all test cases and examples, complemented by MSSQL specific documentation. If you are building enterprise software, you can request commercial access. It is currently based on SeaORM 1.0, but we will offer free upgrade to existing users when SeaORM 2.0 is finalized.
Releases
SeaORM 2.0 has reached its release candidate phase. We'd love for you to try it out and help shape the final release by sharing your feedback.
SeaORM 2.0 is shaping up to be our most significant release yet - with a few breaking changes, plenty of enhancements, and a clear focus on developer experience.
- A Sneak Peek at SeaORM 2.0
- SeaORM 2.0: A closer look
- Role Based Access Control in SeaORM 2.0
- Seaography 2.0: A Powerful and Extensible GraphQL Framework
- SeaORM 2.0: New Entity Format
- SeaORM 2.0: Entity First Workflow
- SeaORM 2.0: Strongly-Typed Column
- What's new in SeaORM Pro 2.0
- SeaORM 2.0: Nested ActiveModel
If you make extensive use of SeaQuery, we recommend checking out our blog post on SeaQuery 1.0 release:
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
We invite you to participate, contribute and together help build Rust's future.
A big shout out to our contributors!
Who's using SeaORM?
Here is a short list of awesome open source software built with SeaORM. Feel free to submit yours!
| Project | GitHub | Tagline |
|---|---|---|
| Zed | A high-performance, multiplayer code editor | |
| OpenObserve | Open-source observability platform | |
| RisingWave | Stream processing and management platform | |
| LLDAP | A light LDAP server for user management | |
| Warpgate | Smart SSH bastion that works with any SSH client | |
| Svix | The enterprise ready webhooks service | |
| Ryot | The only self hosted tracker you will ever need | |
| Lapdev | Self-hosted remote development enviroment | |
| System Initiative | DevOps Automation Platform | |
| OctoBase | A light-weight, scalable, offline collaborative data backend |
Sponsorship
SeaQL.org is an independent open-source organization run by passionate developers. If you feel generous, a small donation via GitHub Sponsor will be greatly appreciated, and goes a long way towards sustaining the organization.
Gold Sponsors
QDX pioneers quantum dynamics-powered drug discovery, leveraging AI and supercomputing to accelerate molecular modeling. We're immensely grateful to QDX for sponsoring the development of SeaORM, the SQL toolkit that powers their data intensive applications.
Silver Sponsors
We're grateful to our silver sponsors: Digital Ocean, for sponsoring our servers. And JetBrains, for sponsoring our IDE.
Mascot
A friend of Ferris, Terres the hermit crab is the official mascot of SeaORM. His hobby is collecting shells.
π¦ Rustacean Sticker Pack
The Rustacean Sticker Pack is the perfect way to express your passion for Rust. Our stickers are made with a premium water-resistant vinyl with a unique matte finish.
Sticker Pack Contents:
- Logo of SeaQL projects: SeaQL, SeaORM, SeaQuery, Seaography
- Mascots: Ferris the Crab x 3, Terres the Hermit Crab
- The Rustacean wordmark
Support SeaQL and get a Sticker Pack! All proceeds contributes directly to the ongoing development of SeaQL projects.