使用Javascript直接在浏览器中读取Sqlite3的最佳方法是什么? [英] What's the best way to read Sqlite3 directly in Browser using Javascript?

查看:657
本文介绍了使用Javascript直接在浏览器中读取Sqlite3的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我们的一个Insights平台,我们计划在后台生成摘要SQLite3数据库,并将其作为图表在浏览器上呈现。目前,我们打算服务于服务于数据需求的服务器端端点。

For one of our Insights platform, we plan to generate summary SQLite3 databases in the background and let it be rendered on the browser as charts. Currently, we are intending to a server-side endpoint that will service the data requirement.

我们希望通过完全取消服务器端端点来进一步优化这一点。我们很好(从安全角度来看)直接在S3上公开SQLite3并读取javascript模块并生成图表。

We are looking to optimize this further by eliminating the server-side endpoint altogether. We are fine (from a security perspective) to expose the SQLite3 directly on S3 and have a javascript module read and generate the charts.

SQLite3文件预计相当小 - 可能是4-6列,也许是10-500行数据,而且所有这些都只包含一个表。测试运行表明文件大小小于15KB。
我们不打算在浏览器上编写或操作SQLite3。
我们不需要将它作为WebSQL或IndexedDB表单缓存在浏览器上,但如果需要,我们可以使用它们。

The SQLite3 files are expected to fairly small - perhaps 4-6 columns and perhaps 10-500 rows of data, and all of them containing one table only. Test runs indicate file sizes of less than 15KB. We don't intend to write or manipulate the SQLite3 on the browser. We don't need to cache it on the browser as a WebSQL or an IndexedDB form, but we are ok with using them if that is what is needed.

从我的网络搜索中,我们无法找到可以读取SQLite3文件并查询结果的Javascript库。如果您知道任何可以执行此操作的JavaScript库,请告诉我们。

From my web searches, We are unable to find a Javascript library that can read a SQLite3 file and query it for results. If you know of any javascript libraries that can do this, then please let us know.

另一方面,如果您认为我们不应该这样做无论出于何种原因,请将它们作为评论/答案抛出,因为这是我们第一次尝试的东西,看起来有点开箱即用,欢迎反馈!

On the other hand, if you think that we shouldn't be doing this for whatever reason, then please throw them as comments/answers too, because this is something we are trying for the first time and seems a little out-of-the-box, so feedback welcome!

推荐答案

我说不出最好,只有一个:自己编写一个JavaScript SQLite阅读器库。这将是一项繁琐的工作,但我是确定它可以完成。一些很酷的人已经完成了 pdf.js ,这是一个PDF文件的JavaScript渲染器,也是二进制BLOB就像 SQLite文件一样。

I can not tell the best, but one: Write a JavaScript SQLite reader library yourself. This will be a tedious task, but I am sure it can be done. Some cool folks have done pdf.js, which is a JavaScript renderer for PDF files, which are also binary BLOB's like SQLite files are.

您最有可能从 FileReader API 开始,通过SQLite文件,然后创建一些内容的内存表示,您的图表工具可以使用。

You will most probably start with the FileReader API to walk thru the SQLite file, then create some in-memory representation of the content, which your chart tool can use.

免责声明:您可能想用另一个解决方案解决您的初始问题,正如其他人所建议的,但这回答了你的问题。

这篇关于使用Javascript直接在浏览器中读取Sqlite3的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆