You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -136,11 +144,14 @@ Alternatively, you can simply download the file `sql.js`, from the download link
136
144
#### read a database from the disk:
137
145
```javascript
138
146
var fs =require('fs');
139
-
varSQL=require('sql.js');
147
+
varinitSqlJs=require('sql-wasm.js');
140
148
var filebuffer =fs.readFileSync('test.sqlite');
149
+
150
+
initSqlJs().then(function(SqlJs){
151
+
// Load the db
152
+
var db =newSqlJs.Database(filebuffer);
153
+
});
141
154
142
-
// Load the db
143
-
var db =newSQL.Database(filebuffer);
144
155
```
145
156
146
157
#### write a database to the disk
@@ -159,12 +170,12 @@ See : https://github.com/kripken/sql.js/blob/master/test/test_node_file.js
159
170
If you don't want to run CPU-intensive SQL queries in your main application thread,
160
171
you can use the *more limited* WebWorker API.
161
172
162
-
You will need to download `worker.sql.js`
173
+
You will need to download `worker.sql-wasm.js`
163
174
164
175
Example:
165
176
```html
166
177
<script>
167
-
var worker =newWorker("js/worker.sql.js"); // You can find worker.sql.js in this repo
178
+
var worker =newWorker("dist/worker.sql-wasm.js"); // You can find worker.sql.js in this repo
168
179
worker.onmessage= () => {
169
180
console.log("Database opened");
170
181
worker.onmessage=event=> {
@@ -189,11 +200,31 @@ Example:
189
200
190
201
See : https://github.com/kripken/sql.js/blob/master/test/test_worker.js
191
202
192
-
## Downloads
193
-
- You can download `sql.js` here : https://raw.githubusercontent.com/kripken/sql.js/master/js/sql.js
194
-
- And the Web Worker version: https://raw.githubusercontent.com/kripken/sql.js/master/js/worker.sql.js
195
-
- You can find a non minified or optimized version for debugging, `sql-debug.js` here : https://raw.githubusercontent.com/kripken/sql.js/master/js/sql-debug.js
196
-
- If you see the message, `Cannot enlarge memory arrays`, try this version, `sql-memory-growth.js` here : https://raw.githubusercontent.com/kripken/sql.js/master/js/sql-memory-growth.js
203
+
## Flavors/versions Targets/Downloads
204
+
205
+
This library includes both asm.js and WebAssembly versions of Sqlite. (WebAssembly is the newer, preferred way to compile to Javascript, and has superceded asm.js. It produces smaller, faster code.) Asm.js versions are included for compatibility.
206
+
207
+
## Upgrading from previous versions
208
+
209
+
Version 1.0 of sql.js introduces a number of breaking changes due primarily to the fact that WASM must be loaded asynchronously, whereas asm.js was able to be loaded synchronously.
210
+
211
+
TODO: More info here:
212
+
213
+
214
+
## Versions of sql.js included in `dist/`
215
+
- `sql-wasm.js` : The Web Assembly version of Sql.js. Minified and suitable for production. Use this. If you use this, you will need to include/ship `sql-wasm.wasm` as well.
216
+
- `sql-wasm-debug.js` : The Web Assembly, Debug version of Sql.js. Larger, with assertions turned on. Useful for local development. You will need to include/ship `sql-wasm-debug.wasm` if you use this.
217
+
- `sql-asm.js` : The older asm.js version of Sql.js. Slower and larger. Provided for compatiblity reasons.
218
+
- `sql-asm-memory-growth.js` : Asm.js doesn't allow for memory to grow by default, because it is slower and de-optimizes. If you are using sql-asm.js and you see this error (`Cannot enlarge memory arrays`), use this file.
219
+
- `sql-asm-debug.js` : The _Debug_ asm.js version of Sql.js. If using sql-asm.js, use this for local development.
220
+
- `worker.*` - Web Worker versions of the above libraries
221
+
Asm.js builds are included for backwards compatilbility.
222
+
223
+
## Compiling
224
+
225
+
- Install the EMSDK, [as described here](https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html)
0 commit comments