问题描述
我有一组 HTML 文件和一个 SQLite 数据库,我想使用 file://方案从浏览器访问它们.是否可以使用 JavaScript 访问数据库并创建查询(和表)?
I have a set of HTML files and a SQLite database, which I would like to access from the browser, using the file:// scheme. Is it possible to access the database and create queries (and tables) using JavaScript?
推荐答案
其实答案是肯定的.以下是如何执行此操作的示例:http://html5doctor.com/introducing-web-sql-databases/
Actually the answer is yes. Here is an example how you can do this: http://html5doctor.com/introducing-web-sql-databases/
不好的是浏览器对它的支持非常有限.
The bad thing is that it's with very limited support by the browsers.
此处的更多信息HTML5 IndexedDB、Web SQL 数据库和浏览器战争
PS:正如@Christoph 所说,Web SQL 不再处于积极维护状态,而 Web 应用程序工作组会这样做不打算进一步维护它,所以请看这里https://developer.mozilla.org/en-US/docs/IndexedDB.
PS: As @Christoph said Web SQL is no longer in active maintenance and the Web Applications Working Group does not intend to maintain it further so look here https://developer.mozilla.org/en-US/docs/IndexedDB.
编辑
正如@clentfort 所说,您可以使用 SQL.js 使用客户端 JavaScript 访问 SQLite 数据库.
As @clentfort said, you can access SQLite database with client-side JavaScript by using SQL.js.
这篇关于是否可以从 JavaScript 访问 SQLite 数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!