SQLite fork adapted to work with Fluence the protocol. The current version is based on SQLite version 3.40.1. The artifact is SQLite WASM module:
- that is compiled following Marine runtime ABI conventions
- to be used with Marine runtime
Wasm module can be built with either docker-compose
docker-compose up
or using this Makefile with GNU make. There are prerequisites to be installed following this path, namely wasi-sdk and marine crate. Take a look at the Dockerfile for the details.
make
The SQLite Wasm module exports a set of SQLite C API functions. The easiest way to try this module is to run it with Marine REPL.
You can find MREPL output for a simple "CREATE-INSERT-SELECT" scenario below. Mind the second argument to sqlite3_open_v2() that is an OR-ed SQLite flag values. The value "6" in this context means SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE
.
$cargo install mrepl
...
$mrepl -q Config.toml
1> call sqlite3 sqlite3_open_v2 [":memory:",6,""]
result: {
"db_handle": 198600,
"ret_code": 0
}
elapsed time: 357.556µs
2> call sqlite3 sqlite3_exec [198600, "CREATE TABLE tab1(i bigint);", 0, 0]
result: {
"err_msg": "",
"ret_code": 0
}
elapsed time: 1.736661ms
3> call sqlite3 sqlite3_exec [198600, "INSERT INTO tab1 VALUES (42);", 0, 0]
result: {
"err_msg": "",
"ret_code": 0
}
elapsed time: 330.098µs
4> call sqlite3 sqlite3_prepare_v2 [198600, "SELECT * FROM tab1;"]
result: {
"ret_code": 0,
"stmt_handle": 244584,
"tail": 268147
}
elapsed time: 280.668µs
5> call sqlite3 sqlite3_step [244584]
result: 100
elapsed time: 124.122µs
6> call sqlite3 sqlite3_column_int64 [244584,0]
result: 42
elapsed time: 72.483µs
You can also try the SQLite Wasm module using Rust together with this Sqlite connector. Here you can find a simple SQL REPL utility example built into a Wasm module.
Please, file an issue if you find a bug. You can also contact us at Discord or Telegram. We will do our best to resolve the issue ASAP.
Any interested person is welcome to contribute to the project. Please, make sure you read and follow some basic rules.
All software code is copyright (c) Fluence Labs, Inc. under the Apache-2.0 license.