
SQLite compiled into JavaScript via Emscripten - sea6ear
https://github.com/kripken/sql.js
======
rhc2104
Sql.js is awesome. It powers sqlteaching.com (on the client side), and the
whole site took about 50 hours of work between my wife and I. Most of that
time was on the curriculum.

~~~
amorphid
[http://sqlteaching.com](http://sqlteaching.com) => cool site! Playing with it
now.

~~~
tomcampbell
Impressive work. Should be a megahit. That 50 hours was very well spent.

------
SEJeff
FYI this is what powers the interactive SQL engine for the SQL classes on the
Khan Academy. If you've never seen them, it is really cool.

[http://www.brianbondy.com/blog/168/sql-on-khan-academy-
enabl...](http://www.brianbondy.com/blog/168/sql-on-khan-academy-enabled-by-
sqlite-sqljs-asmjs-and-emscripten)

[https://www.khanacademy.org/computing/computer-
programming/s...](https://www.khanacademy.org/computing/computer-
programming/sql)

------
timeu
Would be interesting to see how this benchmarks against the in-memory db of
lovefield
([https://github.com/google/lovefield](https://github.com/google/lovefield))

------
myoon
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.

~~~
bobajeff
>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?

~~~
AndrewGaspar
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.

~~~
TazeTSchnitzel
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.

------
pygy_
What I would love to see is a SQLite rewrite in Rust. Just enough to support
WebSQL and appease Mozilla's concern about the lack of alternative
implementations.

~~~
saidajigumi
"What I would love to see is a $PROJ rewrite in Rust." has kinda become a
mantra of mine, particularly for things like SQLite which are core
dependencies of so many other things.

~~~
WaxProlix
The problem is that it isn't so much about an interface-compatible version of
$project in Rust - the value of things like SQLite is in the huge amount of
testing and perf work that's been done over the years. You could do a toy
reimplementation, but the value wouldn't be there.

~~~
rcthompson
Luckily a huge amount of that testing work has been captured in a
comprehensive test suite for SQLite that any alternative implementation could
easily use to ensure compatibility.

~~~
monocasa
Last time I checked, the majority of the test suite was proprietary.

~~~
thomasz
You can buy a license for the test suite and run it against your own
implementation.

------
SunboX
Did someone try to compile Zebra Crossing (ZXing) to JavaScript using
Emscripten? I searched a lot, but sadly didn't find anyone who succeeded. And
I don't have enough knowledge about C++ to try it myself.

~~~
nly
The C++ version of ZXing is no longer maintained. Unless you really need
everything clientside, I'd just go wrap the Java library in a RPC like Thrift
and bolt it in to your backend.

------
kgen
SQL.js is a great library -- we use it on
[http://sqlbolt.com/](http://sqlbolt.com/) to teach SQL right in the browser
in a platform agnostic way.

------
cheyne
Been using this library for a while now. Works great, I based my app
[https://www.lightroomdashboard.com](https://www.lightroomdashboard.com) on it

~~~
bambax
Wow, really amazed with your app!! My catalog is 500Mo and was analysed super
fast! Love the filters too and the ability to restrict the period (it would be
even nicer if we could move some sliders to analyse a specific period).
Anyway, this is totally amazing! ;-)

\---

Now this is really, completely OT, but since you seem to be an expert with
Lightroom catalogs, I wonder if you would know the answer to the following
problem.

I had been using Lightroom 3 for a very long time, with newer cameras the RAWs
of which it couldn't read, so I converted the RAW files to DNG using the Adobe
utility. This was fine but used double disk space.

Now I finally upgraded Lightroom; I still have the original RAW files and was
wondering if I could somehow replace the pointers to the DNGs with the
original RAWs in the .lrcat catalog file; would that work, or completely break
everything? (The point being, to get rid of the DNG files on disk).

------
seanalltogether
I wonder how well this would work for shipping game assets in the browser. One
of the nice things I miss about flash was having a single compiled object to
store on the server and distribute to end users which contained all the assets
and sounds needed for the game. Stuffing all your assets into a sqlite
database and sending that over the wire would keep everything nice and tidy.

~~~
azakai
SQLite does mean you'll have overhead in retrieving that data, though. If you
want to be able to do SQL queries on it, it's worth it, but otherwise it's
probably not.

If you just want a single file, you can bundle all the assets into one and
emit some metadata so you know where each file starts and ends. Emscripten's
file packager does this, for example.

------
inglor
I wrote an SQL injection tutorial using this a while ago:
benjamingr.github.io/PizzaHack

------
PSeitz
I would be very interested in benchmarks comparing it to the native version

------
omegote
ITT: people advertising their SQL-teaching websites.

