javascript - sqlite read DB - reference sql.js library with locate file
问题描述
I was using this answer to read my db, but this solution is not working any more. It returns now Promise { <state>: "pending" }
> . I tried to replace locateFile parameter like this inside promise:
locateFile: file => `dist/${file}`
where dist is folder in initial directory,but no success. Complete code:
<html>
<head>
<script src='dist/sql-wasm.js'></script>
<script type="module">
const sqlPromise = initSqlJs({
locateFile: file => `dist/${file}`
});
const dataPromise = fetch("http://localhost/jsons/wind_prev.db").then(res => res.arrayBuffer());
const [SQL, buf] = await Promise.all([sqlPromise, dataPromise])
const db = new SQL.Database(new Uint8Array(buf));
console.log(db)
</script>
</head>
</html>
I believe this has to do something with removing library from https://sql.js.org/dist
, but im not sure if i can refrence it within local folder without installing additional packages?
Any help is appreceated.
解决方案
推荐阅读
- airflow - Airflow SSH 操作员错误:遇到 RSA 密钥,应为 OPENSSH 密钥
- prolog - 如何为其他谓词中的列表元素添加约束?
- javascript - 使用 SocketIO 和 node.js,只有我发送的消息在聊天室中不可见
- terraform - Terraform - 如何获取在 for_each 块中创建的资源的引用
- javascript - vue 3 和 vue-cli-plugin-i18n
- multithreading - Delphi WebBroker 真正多线程?
- css - 如何在 Wordpress 主题中更改课程
- wordpress - 需要为一个类别的单个产品单独布局
- c# - 我可以为不同的部分重复使用具有相同值的相同单选按钮吗?
- qt - CMake 3.17 在更新 TS 文件时删除 Qt 翻译