Expose details of result column
In connectors like better-sqlite3: sqlite3_column_name and the origins of columns are exposed via Statement.columns, this is useful for analysing a statement.
I've written a connector which uses the Statement.columns method to automatically replace forgein key references with getters, I would like to bring this to the browser via sql.js but that information isn't exposed in this API, or in any other wasm API.
Would you be interested in adding a method similar to better-sqlite3's prepared statements? It's quite a niche thing but most server-side connectors impliment it, so people must be using it.
I have looked a little bit at sql.js' source code and I think I'll be able to impliment it myself and make a pull request, but I've never worked on C and JS in tandem so it would be a learning curve, I just haven't gone on that curve yet in case you think it's a dumb idea and you'll never merge it.
Thanks for your time.
Hello, This is a nice feature, and I would be happy to review your PR ! Don't hesitate to ask if you need help or pointers to get started.
Thank you! When I get some time I will start playing around with it.
Hello, This is a nice feature, and I would be happy to review your PR ! Don't hesitate to ask if you need help or pointers to get started.
Hello, really sorry but I'm stuck at the first hurdle.
- Ran
npm run rebuildgot an error (e=2) about not being able to findrmon path - Added
C:\Program Files\Git\usr\binto path to addrm - Found that if you add
shto path,makeerrors - Removed
shfrom path by renaming it (bodge!) - Now I'm stuck with the following error:
C:\Users\charl\Documents\GitHub\sql.js>make
mkdir -p cache
A subdirectory or file -p already exists.
Error occurred while processing: -p.
make: *** [cache/sqlite-amalgamation-3310100.zip] Error 1
I know this isn't a make support line but lots of the contributers to this project must have had make and git installed while working on this project, so figured you might have an easy fix to this!
Many thanks.
Hello @charlielidbury ! I don't know very much about windows, but I guess the easiest fix is to just not use it for this kind of work :smile: If you don't want to install linux, you can try WSL. It should come with all the tools you need.
Lol I was hoping you wouldn’t say that, used to dual boot for PHP work but stopped using PHP ages ago. If WSL doesn’t work straight away I guess I’m dual booting!
On 7 Jun 2020, at 10:29, Ophir LOJKINE [email protected] wrote:
Hello @charlielidbury ! I don't know very much about windows, but I guess the easiest fix is to just not use it for this kind of work 😄 If you don't want to install linux, you can try WSL. It should come with all the tools you need.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
I personally don't use windows, but I've heard a lot of good things about WSL2. Hope you can make it work :)
I'm a windows user, who runs linux stuff under debian docker. don't know about wsl2, but was not impressed with wsl1 -- things would randomly crash under it.
i don't actually compile sqj.js or bother with emscripten tooling locally. just let github-ci do the heavy-lifting (takes 5 minutes) and then download it's artifacts.
I wouldn't recommend this workflow. The CI has to reinstall emscripten every time you launch it, and as you noticed, it takes several minutes. Setting up emscripten locally is a little bit painful, but it's a one-time job, which then lets you test your changes and iterate on them rapidly.
Hello, been sitting on this issue for a day now with no success.
When I add _sqlite3_column_count to exported_functions.json, it compiles just fine, then I can use cwrap to call it within api.js
If I add _sqlite3_column_origin_name to exported_functions.json, it errors with:
emcc --memory-init-file 0 -s RESERVED_FUNCTION_POINTERS=64 -s ALLOW_TABLE_GROWTH=1 -s EXPORTED_FUNCTIONS=@src/exported_functions.json -s EXTRA_EXPORTED_RUNTIME_METHODS=@src/exported_runtime_methods.json -s SINGLE_FILE=0 -s NODEJS_CATCH_EXIT=0 -s INLINING_LIMIT=50 -O3 -flto --llvm-lto 1 --closure 1 -s WASM=0 out/sqlite3.bc out/extension-functions.bc --pre-js src/api.js -o dist/sql-asm.js
emcc:WARNING: --llvm-lto ignored when using llvm backend
emcc: error: undefined exported function: "_sqlite3_column_origin_name" [-Wundefined] [-Werror]
make: *** [Makefile:95: dist/sql-asm.js] Error 1
Which makes it look like column_origin_name should have been exported somewhere but it doesn't. I had a look in sqlite3.c and it looks to be exporting sqlite3_column_origin_name, so I don't know what to do to make sqlite3_column_origin_nameaccessable withinapi.js`