rbdc-sqlite 4.9.3

The Rust SQL Toolkit and ORM Library. An async, pure Rust SQL crate featuring compile-time Dynamic SQL
Documentation

rbdc-sqlite

SQLite database driver for the rbdc database abstraction layer.

Features

  • High-performance async connection based on libsqlite3
  • Full SQLite data type support
  • Connection pooling support
  • Zero-copy serialization/deserialization
  • Bundled SQLite support (no external dependencies)
  • SQLCipher encryption support (optional)

Supported Connection String Formats

1. In-memory database

sqlite://:memory:

2. File-based database

sqlite://path/to/database.db

Usage

use rbdc::pool::ConnectionManager;
use rbdc_sqlite::SqliteDriver;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // In-memory database
    let uri = "sqlite://:memory:";

    // Or file-based database
    // let uri = "sqlite://path/to/database.db";

    // Create connection manager
    let manager = ConnectionManager::new(SqliteDriver {}, uri)?;

    // Use connection pool
    let pool = rbdc_pool_fast::FastPool::new(manager)?;
    let mut conn = pool.get().await?;

    // Execute query
    let result = conn.exec_decode("SELECT 1 as test", vec![]).await?;
    println!("Result: {:?}", result);

    Ok(())
}

RBDC Architecture

  • Database driver abstraction layer
  • Zero-copy serialization/deserialization

Data flow: Database -> bytes -> rbs::Value -> Struct(User Define) Reverse: Struct(User Define) -> rbs::ValueRef -> ref clone() -> Database

How to Define a Custom Driver?

Implement the following traits and load the driver:

  • impl trait rbdc::db::{Driver, MetaData, Row, Connection, ConnectOptions, Placeholder}

Dependencies

License

This project is licensed under the same license as rbdc.