5 ms·
SQL.js: SQLite Compiled to JavaScript via Emscripten
- pixelcort 15y agoAs mentioned in the article, this could be adapted to make a useful polyfill for those browsers which don't offer SQLite access natively.
- malkia 15y agoFor a second I thought polyfill, as in polygon fill :)
- riffraff 15y agoI may be wrong, but I doubt there are people using WebSQL storage as an in memory database that will be wiped out as soon as the page is closed.
- bradhe 15y agoIt does open up some really interesting scenarios, though. For instance, I know a company that displays a large amount of data to it's users, so sticking that in WebSQL is useful to them as it makes that data easily queryable. However, since data is their thing they don't want it to persist!
- malkia 15y agoI understand when this is done in a server, where you have control of how big your instance can be, but wouldn't that put too much memory pressure on the browser? What if the browser client is 32-bit? Even in Chrome where each page has a separate process one can make it go out of memory.
- pork 15y agoI think he was referring to the data manipulation capabilities of SQL, things like GROUP BY and WHERE and ORDER BY that can be offloaded to the client, not as a data caching benefit.
- wavephorm 15y agoCould this be embedded inside NodeJS thus eliminating the need for a driver?
- gcr 15y agoI'd much rather use a driver than use this. Both require installing 3rd-party packages, so why would you want to do this? It would be interesting to see the performance of Emscripten SQLite. Can node.js and the V8 engine itself be compiled to JS? Could be interesting for sandboxing.
- simcop2387 15y agoI doubt the V8 Engine could be easily done so, you'd have to remove the JIT and all of that in order to do so otherwise it will be dependent on having some kind of emulated processor to do it. Though such a thing does exist...
- wavephorm 15y agoWell for one, this SQLite.js is completely useless without persistence. All you need is some way to get the contents of the database and save it to a file. That way if you have some new type of architecture that's not supported by SQLite, but you do have a JavaScript VM available you could really easily whip up an SQLite based app without going to the trouble of porting SQLite itself.
- lukifer 15y agoIt would be nice if you could bake in schema and data with SQL.js itself; it might be useful for querying static data, such as a local auto-complete.
- mcantelon 15y ago>I'd much rather use a driver than use this. Both require installing 3rd-party packages, so why would you want to do this? If you're running Windows and can't compile the existing driver.
- xxiao 15y agonot sure how useful this is, is the database stored in memory? how is it persistent? also non-blocking access is key otherwise you can easily freeze the UI.
- devongovett 15y agoI think it's memory for now, but I'm hoping for an IndexedDB backend as a polyfill for WebSQL. As for non-blocking... that's what Web Workers are for :)
- baq 15y agogreat for teaching SQL, perhaps? super easy example queries, etc.
- hogu 15y agoin memory data bases can be very useful! they allow you to slice and dice and aggregate data without you having to write the logic to do that yourself. I'm guessing this is in memory, the main purpose would be for you to use sqlite in the browser since node already has a sqlite driver, as such, IO blocking is not an issue because there is no IO, it can block the same way that cpu intensive code can block however
- oscilloscope 15y agoYou can avoid blocking by running SQL.js in a Web Worker.
- spin 15y agoActually, I'd love to be able to write SELECT queries in Javascript that were identical to the queries that I write on the server. Yeah, the data comes from an AJAX-JSON call, but then I deal with it exactly the same. I'd love that.
- deleted 15y ago[deleted]
- kpozin 15y agoWarning: clicking "execute" on the demo page made my machine unresponsive and caused the hard drive to thrash for about five minutes before I could finally kill chrome.exe (I'm running a recent version on the Chrome beta channel).
- bartl 15y agoFrom the [readme](https://github.com/kripken/sql.js/blob/master/README.markdown https://github.com/kripken/sql.js/blob/master/README.markdow...): >sql.js is a port of SQLite to JavaScript, by compiling the SQLite C code with Emscripten. sql.js itself is 1 line of (incomprehensible) code, 907kB in size. Uh, wow.