Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/darkskygit/sqlite-vfs-http
Query sqlite database over http
https://github.com/darkskygit/sqlite-vfs-http
cdn http-client sqlite sqlite-vfs sqlite3
Last synced: 29 days ago
JSON representation
Query sqlite database over http
- Host: GitHub
- URL: https://github.com/darkskygit/sqlite-vfs-http
- Owner: darkskygit
- License: agpl-3.0
- Created: 2024-12-25T12:29:30.000Z (about 1 month ago)
- Default Branch: master
- Last Pushed: 2024-12-26T03:14:36.000Z (about 1 month ago)
- Last Synced: 2024-12-26T04:20:41.430Z (about 1 month ago)
- Topics: cdn, http-client, sqlite, sqlite-vfs, sqlite3
- Language: Rust
- Homepage:
- Size: 40 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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`:
```toml
[dependencies]
sqlite-vfs-http = "0.1.0"
```2. use the library in your code:
```rust
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::(0)
).unwrap();
```### Limitations
- Before uploading to the CDN, the database needs to change the journal mode to `MEMORY`:
```sql
PRAGMA journal_mode = MEMORY;
```### License
> This project is licensed under the AGPL-3.0 license.