| Crates.io | rbdc |
| lib.rs | rbdc |
| version | 4.7.0 |
| created_at | 2022-08-06 09:45:07.789624+00 |
| updated_at | 2026-01-04 16:48:19.053834+00 |
| description | The Rust SQL Toolkit and ORM Library. An async, pure Rust SQL crate featuring compile-time Dynamic SQL |
| homepage | https://rbatis.github.io/rbatis.io |
| repository | https://github.com/rbatis/rbatis |
| max_upload_size | |
| id | 639781 |
| size | 149,736 |
Database driver abstraction layer for Rust, providing a unified interface for rbatis.
#![forbid(unsafe_code)] - 100% safe Rust| Database | Driver |
|---|---|
| MySQL | rbdc-mysql |
| PostgreSQL | rbdc-pg |
| SQLite | rbdc-sqlite |
| MSSQL | rbdc-mssql |
use rbdc_sqlite::SqliteDriver;
use rbdc_pool_fast::FastPool;
#[tokio::main]
async fn main() -> Result<(), rbdc::Error> {
let pool = FastPool::new_url(SqliteDriver {},"sqlite://target/test.db")?;
let mut conn = pool.get().await?;
let v = conn.get_values("SELECT * FROM sqlite_master", vec![]).await?;
println!("{}", v);
//if need decode use `let result:Vec<Table> = rbs::from_value(v)?;`
Ok(())
}
Implement these 6 traits:
use rbdc::db::{Driver, MetaData, Row, Connection, ConnectOptions, Placeholder};
impl Driver for YourDriver {}
impl MetaData for YourMetaData {
//TODO imple methods
}
impl Row for YourRow {
//TODO imple methods
}
impl Connection for YourConnection {
//TODO imple methods
}
impl ConnectOptions for YourConnectOptions {
//TODO imple methods
}
impl Placeholder for YourPlaceholder {
//TODO imple methods
}
/// use your driver
#[tokio::main]
async fn main() -> Result<(), rbdc::Error> {
let uri = "YourDriver://****";
let pool = FastPool::new_url(YourDriver{}, uri)?;
let mut conn = pool.get().await?;
let v = conn.get_values("SELECT 1", vec![]).await?;
println!("{}", v);
}
For databases with blocking APIs, refer to rbdc-sqlite which uses the flume channel library.
See examples for more.
MIT