Teil, basic data mapper for Postgres/Sqlite
Teil (pronounced /tail/)is a library that intends to make a connection to postgres (or sqlite) as simple as possible (with the limitations that this implies). Teil means part, portion or piece in german.
# async fn async_main() {
use teil::{Teil, fields::Serial};
#[derive(Teil, Debug)]
struct Account {
#[teil(auto, primary_key)]
id: Serial,
#[teil(unique)]
owner: String,
#[teil(rename = "account_balance")]
balance: f64
}
teil::config()
.user("example")
.password("password")
.dbname("example_db")
.host("127.0.0.1")
.port(5432)
.set().unwrap();
teil::create!(Account);
(Account {id: Serial::new(), owner: "Carlos".into(), balance: 420.00}).save().await.unwrap();
let account = Account::retrieve(1).await.unwrap();
println!("{:?}", account);
teil::destroy!(Account);
# }