企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[TOC] ## 示例 常用文件 test/jswasm/sqlite3.js https://sqlite.org/wasm/doc/tip/jswasm/sqlite3.js test/jswasm/sqlite3.wasm https://sqlite.org/wasm/doc/tip/jswasm/sqlite3.wasm test/demo-123.js https://sqlite.org/wasm/doc/tip/demo-123.js ``` <!doctype html> <html lang="en-us"> <head> <meta charset="utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon"> <title>Hello, sqlite3</title> <style> .warning, .error {color: red} .error {background-color: yellow} body { display: flex; flex-direction: column; font-family: monospace; white-space: break-spaces; } </style> </head> <body> <h1>1-2-sqlite3 demo</h1> <script src="test/jswasm/sqlite3.js"></script> <!--<script src="test/demo-123.js"></script>--> <script> window.log=function (...a) { console.log(a) } window.sqlite3InitModule().then(function(sqlite3){ // The module is now loaded and the sqlite3 namespace // object was passed to this function. console.log("sqlite3:", sqlite3); const capi = sqlite3.capi/*C-style API*/, oo = sqlite3.oo1/*high-level OO API*/; log("sqlite3 version",capi.sqlite3_libversion(), capi.sqlite3_sourceid()); const db = new oo.DB("/mydb.sqlite3",'ct'); try { db.exec({ sql:`CREATE TABLE im_id ( TBL_NAME varchar(50) NOT NULL DEFAULT '' , TBL_MAXID bigint(20) DEFAULT 0 , PRIMARY KEY (TBL_NAME) );` }) db.exec({ sql:`INSERT INTO im_id(TBL_NAME, TBL_MAXID) VALUES (?, ?)`, bind:["123",123] }); db.exec({ sql:`INSERT INTO im_id(TBL_NAME, TBL_MAXID) VALUES (?, ?)`, bind:["1234",123] }); var res = db.exec({ sql:"select * from im_id", rowMode:'array', callback:function (row) { console.log(row); // ['123', 123] // ['1234', 123] } }) }finally { db.close() } }); </script> </body> </html> ```