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
The sample demo in the readme seems intimidating...
Here's a simpler one:
<head><title>Demo</title><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/sql.js/1.12.0/sql-wasm.js"></script><!-- preload sql-wasm.wasm, if you like --></head><body><buttonid='btn'>Run query</button><scripttype='module'>// Initialize SQL.jsconstSQL=awaitinitSqlJs({locateFile: ()=>`https://cdnjs.cloudflare.com/ajax/libs/sql.js/1.12.0/sql-wasm.wasm`})// Create a db with sample dataconstdb=newSQL.Database()db.run(`CREATE TABLE test (id INTEGER, name TEXT); INSERT INTO test VALUES (1, 'Alice'), (2, 'Bob')`)// Run a queryasyncfunctionrun(){constresult=awaitdb.exec("SELECT * FROM test")console.log(result[0].values)}btn.addEventListener('click',run)</script></body>
For previous versions:
<head><title>Demo</title><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/sql.js/0.5.0/js/sql-optimized.js"></script></head><body><buttonid='btn'>Run query</button><scripttype='module'>constdb=newSQL.Database()db.run(`CREATE TABLE test (id INTEGER, name TEXT); INSERT INTO test VALUES (1, 'Alice'), (2, 'Bob')`)asyncfunctionrun(){constresult=awaitdb.exec("SELECT * FROM test")console.log(result[0].values)}btn.addEventListener('click',run)</script></body>
The text was updated successfully, but these errors were encountered:
The sample demo in the readme seems intimidating...
Here's a simpler one:
For previous versions:
The text was updated successfully, but these errors were encountered: