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.

有帮助吗?

解决方案

JavaScript has HTML5 IndexedDB available to it out of the box.

As for SQLite, you can use it, provided that you first wrap it as a WinRT component that can be consumed from JavaScript, e.g. using C++/CX. Its API surface is not that big, so it's certainly possible. I've experimented with compiling SQLite for Metro a while ago, and there were only a few Win32 API calls that were not available in the app container and had to be replaced - nothing major.

其他提示

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.

Take a look at this: http://sqlwinrt.codeplex.com/

Yes, SQLite database is now supported in Windows 8 RTM. You can now download everything (Windows 8, tools, samples) from Windows Dev Center.

Yes You can use SQLite in WinRT machine. Just follow following steps

  1. Create a new project.
  2. Go to references , then right click on the references there you will get Manage NuPackage Click on that.
  3. In online search for Sqlite-net package , intall that package.
  4. Again right click on the References and click add refrences , there in Extension section you will get two unchecked reference MS visual C++ run time and Sqlite Windows runtime. check both the reference and add references. It will two CS files in your solution explorer.
  5. Now Download Zip file from https://github.com/doo/SQLite3-WinRT It will provide you the wrapper thing to use cs files in your project.
  6. Unzip at any location.
  7. Now in project go to FILE->ADD->Existing Project-> and browse your unzip location . There you will get a file SQLite3Component.vcxproj inside the SQLite3Component. Add that file.
  8. Now wrapper Project is included in you Project.
  9. Now in your unzipped files you ll get SQLite3JS folder copy that folder and paste in your solution explorer.
  10. Now you are ready to use sqlite in your project.
  11. Try to build your project it will show two error that winres.h file is not there. For that go to error location rename it winresrc.h and build it again. Now it will build and you can use sqlite in your project.
    1. To use .js file of SQLite3JS , Provide the src of js file like SQLite3JS\js\SQLite3.js in html page where you are going to use sqlite. Here i am giving you some example to use sqlite in js // This will Create database name db.sqlite and try to create a table Name Notes. If it is not there 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)'); I hope all these step will help you out.
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top