@@ -15,7 +15,8 @@ sql.js can be used like any traditional JavaScript library. If you are building
1515SQLite is public domain, sql.js is MIT licensed.
1616
1717## API documentation
18- A [ full API documentation] ( https://sql.js.org/documentation/class/Database.html ) generated from comments inside the source code is available.
18+ A [ full API documentation] ( https://sql.js.org/documentation/ ) for all the available classes and methods is available.
19+ Is is generated from comments inside the source code, and is thus always up to date.
1920
2021## Usage
2122
@@ -37,19 +38,6 @@ var db = new SQL.Database();
3738// NOTE: You can also use new SQL.Database(data) where
3839// data is an Uint8Array representing an SQLite database file
3940
40- // Execute some sql
41- sqlstr = " CREATE TABLE hello (a int, b char);" ;
42- sqlstr += " INSERT INTO hello VALUES (0, 'hello');"
43- sqlstr += " INSERT INTO hello VALUES (1, 'world');"
44- db .run (sqlstr); // Run the query without returning anything
45-
46- var res = db .exec (" SELECT * FROM hello" );
47- /*
48- [
49- {columns:['a','b'], values:[[0,'hello'],[1,'world']]}
50- ]
51- */
52-
5341// Prepare an sql statement
5442var stmt = db .prepare (" SELECT * FROM hello WHERE a=:aval AND b=:bval" );
5543
@@ -65,6 +53,19 @@ stmt.free();
6553// You can not use your statement anymore once it has been freed.
6654// But not freeing your statements causes memory leaks. You don't want that.
6755
56+ // Execute a single SQL string that contains multiple statements
57+ sqlstr = " CREATE TABLE hello (a int, b char);" ;
58+ sqlstr += " INSERT INTO hello VALUES (0, 'hello');"
59+ sqlstr += " INSERT INTO hello VALUES (1, 'world');"
60+ db .run (sqlstr); // Run the query without returning anything
61+
62+ var res = db .exec (" SELECT * FROM hello" );
63+ /*
64+ [
65+ {columns:['a','b'], values:[[0,'hello'],[1,'world']]}
66+ ]
67+ */
68+
6869// You can also use JavaScript functions inside your SQL code
6970// Create the js function you need
7071function add (a , b ) {return a+ b;}
0 commit comments