如何在Blazor Wasm中读取/导入SQLite数据库?
这甚至可行吗?我只能找到如何使其从应用程序中运行,没有什么能接近文件的导入,这将是byte []
文件,并使其成为可以实例化的客户端并读/写(在内存)。
Is it even feasible? All I can find is how to get it running from within the app and nothing that approaches the import of the file which will be a byte[]
file and make it so that it could be possible to instantiate a client and read/write on it(in memory).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是可能的,但不是很可行,因为如今您会根据我谦虚的实验添加更多数据/表,从而导致一些奇怪的行为/错误。
首先,您通过HTTP调用将文件读取为流,然后将其转换为基本64字符串,
然后,这是 javascript 函数实现:
只是一些额外的注释:
安全上下文:此功能仅在安全上下文(https),某些或所有支持浏览器中可用。
标题:缓存API不符合HTTP缓存标题。
键匹配键匹配算法取决于变化标头在值中。因此,匹配新密钥需要查看
Cache
对象中条目的密钥和值。因此,请确保按名称填充库,并仅使用可以安全操作的脚本版本中的录音。这是 mozilla 的一个示例/docs/web/api/service_worker_api/used_service_workers#deleting_old_caches“ rel =” nofollow noreferrer'>删除旧的cachesIt's possible but not very feasible, as it would lead to some strange behaviors/errors nowadays as you add more data/tables as per my humble experiments.
First, you read the file as a stream via HTTP call and convert it to a base64 string like so:
Then, this is the JavaScript function implementation:
Just a few extra notes:
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Headers: The caching API doesn't honor HTTP caching headers.
key Matching The key matching algorithm depends on the VARY header in the value. So matching a new key requires looking at both key and value for entries in the
Cache
object. For that reason, make sure to version caches by name and use the caches only from the version of the script that they can safely operate on. Here is an example from Mozilla on how to get rid from old caches via vanilla JavaScript: Deleting old caches