https://github.com/apskhem/sea-orm-dbml
DBML to SeaORM entity compiler.
https://github.com/apskhem/sea-orm-dbml
code-generation compiler dbml orm rust sql
Last synced: 3 months ago
JSON representation
DBML to SeaORM entity compiler.
- Host: GitHub
- URL: https://github.com/apskhem/sea-orm-dbml
- Owner: apskhem
- License: apache-2.0
- Created: 2022-09-30T16:03:31.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-05-07T09:45:56.000Z (over 2 years ago)
- Last Synced: 2025-09-19T17:47:06.559Z (4 months ago)
- Topics: code-generation, compiler, dbml, orm, rust, sql
- Language: Rust
- Homepage:
- Size: 173 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# SeaORM DBML
#### Database Markup Language (DBML) compiler for SeaORM Entity.
[](https://crates.io/crates/sea-orm-dbml)



## Why DBML?
DBML (Database Markup Language) is an open-source DSL language designed to define and document database schemas and structures. It is designed to be simple, consistent and highly-readable.
Read more: [Official docs](https://www.dbml.org/home/)
This project aims to make use of DBML as a language for writing SeaORM entity.
## Output
Below is the example of compiling DBML into SeaORM entity.
```dbml
Table user {
id integer [pk]
username varchar
role varchar
}
```
```rust
//! Generated by sea-orm-dbml 0.1.0
pub mod user {
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "user", schema_name = "public")]
pub struct Model {
#[sea_orm(column_type = "Integer", primary_key, auto_increment = false)]
pub id: i32,
#[sea_orm(column_type = "String(None)")]
pub username: String,
#[sea_orm(column_type = "String(None)")]
pub role: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}
impl ActiveModelBehavior for ActiveModel {}
}
```
## How to use it?
```rust
use std::{ffi::OsString, error::Error};
use sea_orm_dbml::{compiler::config::Config, *};
fn main() -> Result<(), Box> {
compile(Config {
in_path: OsString::from("path/to/file.dbml"),
out_path: OsString::from("path/to/out/mod.rs"),
target: compiler::config::Target::Postgres,
..Default::default()
})
}
```
## License
Licensed under either of
- Apache License, Version 2.0
([LICENSE-APACHE](LICENSE-APACHE) or )
- MIT license
([LICENSE-MIT](LICENSE-MIT) or )
## 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.
Always welcome you to participate, contribute and together.