sqlite-objs 0.1.2-alpha

Safe Rust bindings for sqlite-objs - SQLite VFS backed by Azure Blob Storage
Documentation

sqlite-objs - SQLite VFS backed by Azure Blob Storage

This crate provides safe Rust bindings to sqlite-objs, a SQLite VFS (Virtual File System) that stores database files in Azure Blob Storage.

Features

  • Store SQLite databases in Azure Blob Storage (page blobs for DB, block blobs for journal)
  • Blob lease-based locking for safe concurrent access
  • Full-blob caching for performance
  • SAS token and Shared Key authentication
  • URI-based per-database configuration

Usage

Basic Registration (Environment Variables)

use sqlite_objs::SqliteObjsVfs;
use rusqlite::Connection;

// Register VFS from environment variables
SqliteObjsVfs::register(false)?;

// Open a database using the sqlite-objs VFS
let conn = Connection::open_with_flags_and_vfs(
    "mydb.db",
    rusqlite::OpenFlags::SQLITE_OPEN_READ_WRITE | rusqlite::OpenFlags::SQLITE_OPEN_CREATE,
    "sqlite-objs"
)?;
# Ok::<(), Box<dyn std::error::Error>>(())

URI Mode (Per-Database Credentials)

use sqlite_objs::SqliteObjsVfs;
use rusqlite::Connection;

// Register VFS in URI mode (no global config)
SqliteObjsVfs::register_uri(false)?;

// Open database with Azure credentials in URI
let conn = Connection::open_with_flags_and_vfs(
    "file:mydb.db?azure_account=myaccount&azure_container=databases&azure_sas=sv=2024...",
    rusqlite::OpenFlags::SQLITE_OPEN_READ_WRITE | rusqlite::OpenFlags::SQLITE_OPEN_CREATE | rusqlite::OpenFlags::SQLITE_OPEN_URI,
    "sqlite-objs"
)?;
# Ok::<(), Box<dyn std::error::Error>>(())

Explicit Configuration

use sqlite_objs::{SqliteObjsVfs, SqliteObjsConfig};
use rusqlite::Connection;

let config = SqliteObjsConfig {
    account: "myaccount".to_string(),
    container: "databases".to_string(),
    sas_token: Some("sv=2024-08-04&...".to_string()),
    account_key: None,
    endpoint: None,
};

SqliteObjsVfs::register_with_config(&config, false)?;

let conn = Connection::open_with_flags_and_vfs(
    "mydb.db",
    rusqlite::OpenFlags::SQLITE_OPEN_READ_WRITE | rusqlite::OpenFlags::SQLITE_OPEN_CREATE,
    "sqlite-objs"
)?;
# Ok::<(), Box<dyn std::error::Error>>(())