spl.js
spl.js copied to clipboard
SQLite extensions
I need to load stats extension. Is there any way ?
Hi, I am afraid no. It needs to be included during compilation. Also I am not sure about the quality of this extension: It is not an official sqlite extension. But I'd guess with some research you could implement it in plain SQL e.g. https://stackoverflow.com/questions/1123576/how-to-find-nth-percentile-with-sqlite
P.S. I have just seen that sql.js has included the extension-functions.c. So I guess then I could give it a try and add the file from the repo you suggested.
PPS I think this looks quite interesting: https://github.com/nalgeon/sqlean
Hi, thanks for reply, do you have any plans to add loadExtension api ?
Hi, thanks for reply, do you have any plans to add loadExtension api ?
I think - at least to my current understanding - this is impossible because WebAssembly has no way to load/link other wasm files dynamically.
@spaciandd Please checkout the new version. I'll pin this issue and rename it so I can reuse it for other extensions.
Is it possible to add the fuzzy, regexp, and text extensions from the sqlean.js library? I need these extensions for performing certain queries. Or, once I've obtained an ArrayBuffer by using db.save, is it possible to reopen it within sqlean.js and make use of these extended functions?
Is it possible to add the fuzzy, regexp, and text extensions from the sqlean.js library? I need these extensions for performing certain queries.
Sure, should not be too difficult. Could you prepare a PR? - no changes to dist/* please. If you look at the changes for the stats extension it is pretty much the same:
- Maybe update the sqlean submodule to the latest release tag
- Add extensions to Makefile
- Load when a database is created/opened in src/spl.js
- Add a simple test (at least to test/node.js) to see if the extension is working
If you could prepare a PR (mustn't be perfect) then I will merge it (maybe with a bit of refactoring/cleaning).
I will give it a try.
I attempted to perform a build on Debian, but encountered errors that I am unable to resolve.
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.50 (047b82506d6b471873300a5e4d1e690420b582d0)
clang version 18.0.0 (https://github.com/llvm/llvm-project 14028ec0a62210d68a4dd7a046ac79c8c3b7727e)
Target: wasm32-unknown-emscripten
Thread model: posix
Could you make draft PR and share the changes you made?
In fact, I haven't started making any changes yet; I'm just compiling the latest current version of the spl.js code.
Did you initialize the git submodules - especially sqlean? Except that I can see that something seems to be wrong with the stats extension I can not really give you a hint were the problem might be.
Did you initialize the git submodules - especially sqlean? Except that I can see that something seems to be wrong with the stats extension I can not really give you a hint were the problem might be.
I have already run git submodule init.
Today, I discovered the custom function capability of sqlite-wasm, which enables you to write custom functions in JavaScript and subsequently call these functions directly within SQL statements.
https://sqlite.org/wasm/doc/trunk/api-c-style.md#sqlite3_create_function
Is this functionality achievable with Spl.js?
This way, I can utilize custom functions as a substitute for the regexp and text extension.
/wasm/doc/trunk/api-c-style.md#sqlite3_create_function Is this functionality achievable with Spl.js? This way, I can utilize custom functions as a substitute for the regexp and text extension.
Theoretically yes, but it is not implemented. Here is a related issue https://github.com/jvail/spl.js/issues/28 But I think just including the extensions from sqlean would be far easier and more efficient in this case.