| Crates.io | spin-sqlite-connection |
| lib.rs | spin-sqlite-connection |
| version | 0.2.3 |
| created_at | 2024-05-31 06:26:32.455225+00 |
| updated_at | 2025-03-17 09:31:39.978919+00 |
| description | Spin Sqlite Connection abstraction |
| homepage | |
| repository | https://github.com/paulusminus/lipl-storage-spin |
| max_upload_size | |
| id | 1257722 |
| size | 34,078 |
I wrote this crate because i wanted to test sqlite database operations in a Fermyon spin application.
This crate uses conditional compilation. The spin-sdk crate is used for database operation if target-family = "wasm", else the rusqlite crate is used. Then rusqlite connection uses a in-memory database which is used in testing.
const MIGRATIONS: &str = "CREATE TABLE IF NOT EXISTS user (id TEXT PRIMARY KEY, name TEXT NOT NULL, password TEXT NOT NULL);"
const INSERT: &str = "INSERT INTO user (id, name, password) VALUES ('LKtQNwbBsQd9aXgMbmptKP', 'paul', 'password');";
let connection = DbConnection::<Box<dyn std::error::Error>>::try_open_default(Some(MIGRATIONS)).unwrap();
let count = connection.execute(INSERT, &[]).unwrap();
assert_eq!(count, 1);