7

Is it possible to use a Sqlite database in a windows 8 (winRT) javascript application?

What I want to achieve is to download a Sqlite database and store this in local storage before use. I believe some form of local storage is available to javascript based WinRT applications, but I want to know if Sqlite is usable in this scenario.

I'm also aware that the .Net implementation of Sqlite uses some win32 calls and I believe these will not be allowed by the windows8 app cerififcation process.

4

5 回答 5

8

JavaScript 具有开箱即用的 HTML5 IndexedDB。

至于 SQLite,您可以使用它,前提是您首先将其包装为可以从 JavaScript 使用的 WinRT 组件,例如使用 C++/CX。它的 API 表面并没有那么大,所以它肯定是可能的。前段时间我尝试为 Metro 编译 SQLite,只有少数 Win32 API 调用在应用程序容器中不可用,必须更换 - 没什么大不了的。

于 2011-10-20T17:37:23.523 回答
5

We created SQLite3-WinRT for this. It is a WinRT component wrapper for SQLite that passes the Windows metro style app certification. It also includes an easy-to-use JavaScript abstraction.

于 2012-06-05T09:38:15.280 回答
2

看看这个: http ://sqlwinrt.codeplex.com/

于 2011-10-31T06:25:09.887 回答
1

是的,您可以在 WinRT 机器中使用 SQLite。只需按照以下步骤

  1. 创建一个新项目。
  2. 转到引用,然后右键单击那里的引用,您将获得 Manage NuPackage 单击它。
  3. 在网上搜索 Sqlite-net package ,安装那个包。
  4. 再次右键单击 References 并单击 add refrences ,在 Extension 部分中,您将获得两个未选中的参考 MS Visual C++ 运行时和 Sqlite Windows 运行时。检查参考并添加参考。它将在您的解决方案资源管理器中包含两个 CS 文件。
  5. 现在从https://github.com/doo/SQLite3-WinRT下载 Zip 文件, 它将为您提供在项目中使用 cs 文件的包装器。
  6. 在任意位置解压。
  7. 现在在项目中转到 FILE->ADD->Existing Project-> 并浏览您的解压缩位置。在那里,您将在 SQLite3Component 中获得一个文件 SQLite3Component.vcxproj。添加该文件。
  8. 现在包装器项目包含在您的项目中。
  9. 现在,在您解压缩的文件中,您将获得 SQLite3JS 文件夹,复制该文件夹并粘贴到您的解决方案资源管理器中。
  10. 现在您已准备好在项目中使用 sqlite。
  11. 尝试构建您的项目,它将显示 winres.h 文件不存在的两个错误。为此,转到错误位置,将其重命名为 winresrc.h 并再次构建它。现在它将构建,您可以在项目中使用 sqlite。
    1. 要使用 SQLite3JS 的 .js 文件,请在要使用 sqlite 的 html 页面中提供 js 文件的 src,例如 SQLite3JS\js\SQLite3.js。这里我给你一些在 js 中使用 sqlite 的例子 // 这将创建数据库名称 db.sqlite 并尝试创建一个表 Name Notes。如果不存在 var dbPath = Windows.Storage.ApplicationData.current.localFolder.path + '\db.sqlite'; SQLite3JS.openAsync(dbPath) .then(function (db) { return db.runAsync('CREATE TABLE Notes (id TEXT PRIMARY KEY, notes TEXT)'); 我希望所有这些步骤对您有所帮助。
于 2014-12-22T10:16:58.177 回答
1

是的,Windows 8 RTM 现在支持 SQLite 数据库。您现在可以从Windows Dev Center下载所有内容(Windows 8、工具、示例) 。

于 2012-08-15T19:49:28.870 回答