https://github.com/apskhem/sqlx-dbml
https://github.com/apskhem/sqlx-dbml
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/apskhem/sqlx-dbml
- Owner: apskhem
- License: apache-2.0
- Created: 2023-07-18T13:26:35.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-07-23T09:37:56.000Z (almost 3 years ago)
- Last Synced: 2024-04-20T08:01:31.465Z (about 2 years ago)
- Language: Rust
- Size: 40 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# SQLx DBML
#### Database Markup Language (DBML) Code Generation for SQLx Structs.
[](https://crates.io/crates/sqlx-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 generating SQLx structs.
## Output
Below is the example of generating DBML into SQLx structs.
```dbml
Table user {
id integer [pk]
username varchar
role varchar
}
```
```rust
//! Generated by sqlx-dbml 0.1.0
pub mod user {
use sqlx::*;
#[derive(FromRow)]
pub struct Model {
pub id: i32,
pub username: String,
pub role: String,
}
}
```
## How to use it?
```rust
use std::{ffi::OsString, error::Error};
use sqlx_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.