←back to thread

Sqlite3 WebAssembly

(sqlite.org)
506 points whatever3 | 1 comments | | HN request time: 0s | source
Show context
brandonpollack2 ◴[] No.41851864[source]
I was trying to get this working in a rust ecosystem some time ago but none of the blessed.rs sql (rusqlite, sqlx) wrappers seem to take advantage of it yet and wrapping it yourself is a bit tricky since when I was trying I couldn't figure out a way to to get emscripten wasm code to play nice with wasm32-unknown-unknown without some kind of JS wrapper which then requires implementing the interface those crates expect and exposing it from JS. Once that is done in rust itll be great there too!
replies(4): >>41852082 #>>41852996 #>>41853144 #>>41854660 #
1. aabhay ◴[] No.41852996[source]
I have been working on one. If you're interested in working on it or contributing, feel free to chime in here:

https://github.com/rhashimoto/wa-sqlite/discussions/154

This essentially requires that we import the sqlite emscripten build via an extern C header in wasm bindgen, and then we need to re-implement the VFS in rust while compiling it in multi-threaded mode to allow for shared array buffer access. After that is all done, we will be able to access SQLite rows as raw wasm bytes. That gives us the ability to implement a rust-sqlite style wrapper or integration. There would still not be some of the niceties such as connection pooling, but in wasm you likely want to use the db in exclusive mode.