sqlite_pages

Crates.iosqlite_pages
lib.rssqlite_pages
version0.3.1
created_at2025-11-29 02:18:26.898625+00
updated_at2026-01-01 23:22:00.980011+00
descriptionPage-level SQLite database access using sqlite_dbpage virtual table
homepage
repositoryhttps://github.com/halzy/sqlite_pages
max_upload_size
id1956281
size127,953
Benjamin Halsted (halzy)

documentation

README

sqlite_pages

Page-level SQLite database access using the sqlite_dbpage virtual table.

Overview

This library provides direct access to SQLite's raw database pages via the SQLITE_DBPAGE virtual table. This virtual table exposes the underlying database file at the page level, allowing reads and writes of raw binary page content through SQLite's pager layer.

This is not for normal database operations - use standard SQLite queries for reading and writing data.

Build Configuration

Add the following to your .cargo/config.toml:

[env]
LIBSQLITE3_FLAGS = "-DSQLITE_ENABLE_DBPAGE_VTAB"

Without this flag, operations will fail with "no such table: sqlite_dbpage".

Usage

Reading Pages

use sqlite_pages::SqliteIo;

let db = SqliteIo::new("database.db")?;

// Iterate over all pages
db.page_map(.., |page_num, data| {
    println!("Page {}: {} bytes", page_num, data.len());
})?;

Writing Pages

use sqlite_pages::{SqliteIo, TransactionType};

let db = SqliteIo::new("target.db")?;
let mut tx = db.transaction(TransactionType::Immediate)?;

for (page_num, data) in pages {
    tx.set_page_data(page_num, &data)?;
}

tx.commit()?;

Async API

use sqlite_pages::{AsyncSqliteIo, TransactionType};

let db = AsyncSqliteIo::new("target.db").await?;
let tx = db.transaction(TransactionType::Immediate).await?;

tx.set_page_data(1, &page_data).await?;
tx.commit().await?;

Important Notes

  • Page Numbering: All page numbers are 1-based (the first page is page 1, not page 0)
  • Database Corruption Risk: This API bypasses SQLite's safety mechanisms. Writing invalid page data will corrupt your database. Only use this for copying valid pages from another SQLite database.

Transaction Types

  • Deferred: No lock acquired until first read/write operation
  • Immediate: Write lock acquired immediately (recommended for writes)
  • Exclusive: Exclusive lock acquired immediately

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

Commit count: 0

cargo fmt