sqlite-vfs-http

Crates.iosqlite-vfs-http
lib.rssqlite-vfs-http
version0.1.4
created_at2024-12-25 12:33:15.180221+00
updated_at2024-12-29 16:05:51.237268+00
descriptionQuery sqlite database over http
homepage
repositoryhttps://github.com/darkskygit/sqlite-vfs-http
max_upload_size
id1494970
size58,553
DarkSky (darkskygit)

documentation

README

sqlite-vfs-http

The sqlite-vfs-http is a library based on the SQLite VFS extension, designed to access static SQLite files located on a CDN via HTTP/HTTPS protocol.

By using this library, you can host SQLite database files on a remote server and perform queries without downloading the files locally.

Requirements

  • any crate that link SQLite3 to your binary, such as rusqlite, sqlx or libsqlite3-sys

Usage

  1. add the following to your Cargo.toml:
[dependencies]
sqlite-vfs-http = "0.1.0"
  1. use the library in your code:
use rusqlite::{Connection, NO_PARAMS};
use sqlite_vfs_http::{register_http_vfs, HTTP_VFS};


// Register the HTTP VFS for sqlite
register_http_vfs();

let base = "https://example.com";
let conn = Connection::open_with_flags_and_vfs(
    format!("{base}/0.db"),
    OpenFlags::SQLITE_OPEN_READ_WRITE
        | OpenFlags::SQLITE_OPEN_CREATE
        | OpenFlags::SQLITE_OPEN_NO_MUTEX,
    // Use HTTP VFS
    HTTP_VFS,
)?;
conn.query_row(
    "SELECT count(1) FROM sqlite_master WHERE type = 'table'",
    [], |row| row.get::<usize>(0)
).unwrap();

Limitations

  • Before uploading to the CDN, the database needs to change the journal mode to MEMORY:
PRAGMA journal_mode = MEMORY;

License

This project is licensed under the AGPL-3.0 license.

Commit count: 11

cargo fmt