预加载的 Javascript 本地数据库后端(可能吗?)
我最近看到了有关 HTML5 和本地数据库创建和使用的文章。我还看到了一些与现有 Access Db 后端的 Javascript 连接字符串的示例。我有兴趣找到一种方法来构建数据库,预先加载记录,并使用网络应用程序连接和读取数据库。例如,我在 Windows 中使用 Tcl 创建了许多独立应用程序,用于读取 Sqlite Db 文件。本质上,应用程序(.exe 文件)和 Db 文件位于一个文件夹中,并且功能与任何其他 Db 应用程序类似,只是不使用服务器。
我希望能够做同样的事情,但是使用网络应用程序(.html)和 Db 文件。有谁知道这是否可能?举个例子,我想构建一个在任何浏览器中运行的语言应用程序,并在后端保存预加载的单词。因此会有两个文件:Web 应用程序和 db 文件。
任何建议或资源链接将不胜感激。我能想到的唯一接近的办法是通过 Javascript 通过 OLE 连接到 Access,但是我需要一个像 Sqlite 这样的多平台 Db。
谢谢,
东风公司
I have recently seen articles on HTML5 and local Db creation and usage. I have also seen some examples of Javascript connection strings to existing Access Db backends. I am interested in finding a way to build a Db, pre-load it with records, and use a web app to connect and read the Db. For example, I have created many standalone applications with Tcl, in Windows, that read off of Sqlite Db files. Essentially, the application (.exe file) and Db file sit next to each other in a folder and function like any other Db application, except without the use of servers.
I would like to be able to do the same, but with a web app (.html) and Db file. Does anyone know if this is possible? As an example, I wanted to build a language application that runs in any browser, with pre-loaded words saved in the backend. So there would be two files, the web app, and the db file.
Any suggestions or links to resources would be really appreciated. The only thing close that I could come up with was connecting to Access via OLE through Javascript, however I need a Db that is multi-platform like Sqlite.
Thanks,
DFM
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的网络应用程序、其本地数据库和“启动”数据都必须从某个地方开始,因此我假设这一切都在与网络服务器的实时连接期间滚动。当第一次点击出现时,您:
存在吗
设置完成后,该应用程序可能完全是本地的 - 不需要网络连接——只要您在不假设非本地资源的情况下编码即可。
参考资料:
Your web app, its local database, and the "priming" data will all have to start somewhere, so I'll assume this all gets rolling during a live connection to a web server. When this first hit comes in, you:
Once setup is complete, this app could be entirely local -- no net connection required -- as long as you code it without the assumption of non-local resources.
References:
您可以通过 javascript 访问已创建的 sqlite db 文件。查看此链接 http://code.google 的“数据库文件位置”区域。 com/apis/gears/api_database.html
我知道这是针对 Google Gears 的,但 Gears 使用 SQLite,并且该位置在没有 Gears 的情况下仍然适用,并且仅使用 sqlite 数据库文件。
例如,我使用 Firefox 插件“SQLite Manager”在本地计算机上创建一个 sqlite 数据库文件。然后我将该文件复制到 C:\Users\\AppData\Local\Google\Chrome\User Data\Default\databases\file__0
我能够在 Google Chrome 中使用 JavaScript 访问该文件:
您必须小心文件名在 Chrome 中,它会通过 id 号自动命名每个 sqlite 数据库。例如,我必须将 sqlite db 文件名重命名为 14,才能从浏览器中的 JavaScript 读取它。一旦我这样做了,它就像冠军一样工作,我能够访问所有表、数据等。
You can access an already created sqlite db file through javascript. Look at the "Location of Database File" area of this link http://code.google.com/apis/gears/api_database.html
I know this is for Google Gears, but Gears uses SQLite and the location still applies without Gears and only using a sqlite db file.
For example, I used a firefox add-on 'SQLite Manager' to create a sqlite db file on my local machine. I then copied that file to C:\Users\\AppData\Local\Google\Chrome\User Data\Default\databases\file__0
I was able to access the file using JavaScript in Google Chrome:
You have to be careful with the file name in Chrome as it automatically names each sqlite db by an id number. For example, I had to rename my sqlite db file name to 14 to get it to read from JavaScript in the browser. Once I did this, it worked like a champ and I was able to access all tables, data, etc.