News for hackers. Stuff that matters.
Re:SQLite compiled into JavaScript via Emscripten by myoon on Thursday September 10, 2015 @05:18PM (#10200623)
Unfortunately, there are a few major downsides to sql.js:

1. Not API compatible with node-sqlite3, so you can't just drop it in and use it with knex or other wrappers.

2. Doesn't support in-place editing of a db. You have to load the entire DB into memory, modify it, and then save it back, making it unsuitable for any concurrent application.

I love the idea of the project though, and it would be awesome not to have to deal with compiling sqlite or using node-pregyp to build embedded chromium apps.

Re:SQLite compiled into JavaScript via Emscripten by andrewstuart2 on Thursday September 10, 2015 @05:40PM (#10200730)
I think the whole point is that it runs in a browser, where you can't install sqlite otherwise. If you're running node, you can almost certainly run a native binary of sqlite.
Re:SQLite compiled into JavaScript via Emscripten by ecnahc515 on Thursday September 10, 2015 @07:00PM (#10201081)
All good points, but I think the primary use case (in a browser) doesn't experience these downsides nearly as much (JS is single threaded in the browser so concurrent access is not a big deal). It would be nice to use knex with it though..
Re:SQLite compiled into JavaScript via Emscripten by vetrom on Thursday September 10, 2015 @09:00PM (#10201459)
Build a VFS layer that uses something like https://code.google.com/p/limbo-machine/wiki/JS to talk over a websocket or http message proxy to a file store and you get in-place editing. It will probably be hell for the 'usual' usecase of nonconcurrent in-page use however. Also, LOL locking, which is the real utility of SQLite's VFS layer.
Re:SQLite compiled into JavaScript via Emscripten by bobajeff on Thursday September 10, 2015 @06:05PM (#10200851)
>Doesn't support in-place editing of a db.

I wonder why that is. Is it just a fuction they simply didn't create a binding for? Or is it some performance concern?

Re:SQLite compiled into JavaScript via Emscripten by AndrewGaspar on Thursday September 10, 2015 @06:47PM (#10201034)
Not OP, but I imagine it's a couple things: 1) No clear mapping between file APIs that SQLite uses and browser file APIs. 2) SQLite uses blocking file I/O internally which is generally a big no-no for JavaScript due to it being single threaded.
Re:SQLite compiled into JavaScript via Emscripten by TazeTSchnitzel on Thursday September 10, 2015 @07:29PM (#10201177)
SQLite is proably saving files in emscripten's virtual filesystem (emscripten's implementation of fopen() etc. by default makes them work on memory), and the sql.js API just reads and writes the file there.
Re:SQLite compiled into JavaScript via Emscripten by malkia on Thursday September 10, 2015 @06:47PM (#10201033)
there is an VFS layer in sqlite, I haven't used it, but it seems like you can override block I/O operations.