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
Copy file name to clipboardExpand all lines: README.md
+51-47Lines changed: 51 additions & 47 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,59 +19,63 @@ A [full documentation](http://kripken.github.io/sql.js/documentation/#http://kri
19
19
20
20
## Usage
21
21
22
+
By default, *sql.js* uses [wasm](https://developer.mozilla.org/en-US/docs/WebAssembly), and thus needs to load a .wasm file in addition to the javascript library. You can find this file in `./node_modules/sql.js/dist/sql-wasm.wasm` after installing sql.js from npm, and add it to your static assets. Alternatively, you can load the file from a CDN :
23
+
22
24
```javascript
23
-
var initSqlJs =require('sql.js');
25
+
constinitSqlJs=require('sql.js');
24
26
// or if you are in a browser:
25
27
// var initSqlJs = window.initSqlJs;
26
28
27
-
initSqlJs().then(SQL=> {
28
-
29
-
// Create a database
30
-
var db =newSQL.Database();
31
-
// NOTE: You can also use new SQL.Database(data) where
32
-
// data is an Uint8Array representing an SQLite database file
33
-
34
-
// Execute some sql
35
-
sqlstr ="CREATE TABLE hello (a int, b char);";
36
-
sqlstr +="INSERT INTO hello VALUES (0, 'hello');"
37
-
sqlstr +="INSERT INTO hello VALUES (1, 'world');"
38
-
db.run(sqlstr); // Run the query without returning anything
0 commit comments