HTML5:可以在清单的缓存部分中指定 SQlite 数据库吗?
我希望能够将 SQLite 数据库指定为清单文件的 CACHE 部分中的资源。这将允许页面上的脚本以离线模式使用数据库。
我在 HTML5 规范中找不到任何说明这不能完成的内容,但我也没有成功地让它工作。
是否可以?
I'd like to be able to specify an SQLite database as a resource in the CACHE section of a manifest file. This would allow the script on the page to use the database in offline mode.
I cannot find anything in the HTML5 spec that says this cannot be done, but I haven't had any success in getting it working either.
Is it possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
查看 W3C 离线 Web 应用程序规范 (http://www.w3.org/TR /html5/offline.html)似乎没有办法在清单中包含 SQLite 数据库文件。否则,它看起来会采取几乎任何具有相对于网站根目录的已知路径的东西。数据库文件由浏览器在网站特定的单独目录中创建,并且不同浏览器的路径不同。我的解决方案是在第一次调用应用程序时创建并下载数据库 - 能够下载文件会更好,但我没有看到这样做的方法。
Looking at the W3C Offline Web Application spec (http://www.w3.org/TR/html5/offline.html) there doesn't appear to be a way to include SQLite database files in the manifest. Otherwise it looks like it will take just about anything that has a known path relative to the root of the web site. Database files are created by the browser in a separate directory specific to the web site, and the path is different for different browsers. My solution was to create and download the database the first time the application is called - it would be much better to be able to download the file, but I don't see a way to do that.
我玩了一会儿。以下是我的发现:
(Web 工具包)浏览器使用数据库来组织 Web SQL 数据库。 :-)
对于 chrome,它位于 (Mac OS X):
您可以通过 SQLite3
Databases.db
访问它:我的看起来像:
文件
./file__0/5
包含mystorage
的数据库。这些条目是在代码打开数据库时创建的。
我没有找到如何在此数据库中创建条目并为其指定路径或文件名的方法。
I played around with it for a while. Here is what I found:
The (web kit) browser uses a database to organize the Web SQL databases. :-)
For chrome it is in (Mac OS X):
You can access this via SQLite3
Databases.db
:Mine looks like:
The file
./file__0/5
contains the database formystorage
.The entries are created when the code does the opendatabase.
I didn't find a way how to create an entry in this database and give it a path or filename.
这是不可能的。
相反,请将数据库转换为 JSON 对象并将其写入文件。将该文件包含在您的清单中。在另一端,读取 JSON 对象并创建数据库。
效果很好!
It's not possible.
Instead, convert your database to a JSON object and write it to a file. Include that file in your manifest. At the other end, read the JSON object in and create the database.
Works well!
我还发现了一个免费工具,说它可以解决这个问题 - 还没有时间尝试它,但听起来它应该可以完成这项工作:
http://impel.simulacre.org/blog/incrementally_synchronize_html5_databases_transparently.html
I also found a free tool that says it solves this problem - haven't had time to try it yet, but it sounds like it should do the job:
http://impel.simulacre.org/blog/incrementally_synchronize_html5_databases_transparently.html