Can I use Sqlite in a WinRT application (javascript)?

Can I use the Sqlite database in a javascript application for Windows 8 (winRT)?

What I want to achieve is to load the Sqlite database and store it in local storage before use. I believe some forms of local storage are available for javascript-based WinRT applications, but I want to know if Sqlite can be used in this scenario.

I also know that the .NET implementation in Sqlite uses some win32 calls, and I believe that they will not be resolved by the Windows8 application occlusion process.

+7
source share
5 answers

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

As for SQLite, you can use it provided that you first port it as a WinRT component that can be used from JavaScript, for example. using C ++ / CX. Its API surface is not so big, so it is certainly possible. I experimented with compiling SQLite for Metro some time ago, and there were only a few Win32 API calls that were not available in the application container and had to be replaced - nothing serious.

+8
source

We created SQLite3-WinRT for this. This is the WinRT component shell for SQLite, which is being certified as a Windows-style Metro style application. It also includes an easy to use JavaScript abstraction.

+5
source

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

+2
source

Yes, the SQLite database is now supported in Windows 8 RTM. Now you can download everything (Windows 8, tools, samples) from the Windows Development Center .

+1
source

Yes, you can use SQLite on a WinRT machine. Just follow these steps.

  • Create a new project.
  • Go to the links, then right-click on the links where you get NuPackage Management. Click on it.
  • In the online search for the Sqlite-net package, enable this package.
  • Again, right-click on the links and click add refrences, there in the Extension section you will get two unverified MS Visual C ++ links and Sqlite Windows runtime. check links and add links. These are two CS files in your solution browser.
  • Now download the zip file from https://github.com/doo/SQLite3-WinRT It will provide you with a shell for using cs files in your project.
  • Unzip anywhere.
  • Now in the project go to FILE-> ADD-> Existing Project-> and view your place for unpacking. There you will get the SQLite3Component.vcxproj file inside SQLite3Component. Add this file.
  • The wrapper project is now included in your project.
  • Now in your unpacked files you will receive a copy of the SQLite3JS package of this folder and paste it into your research solution.
  • Now you are ready to use sqlite in your project.
  • Try to create your project, it will show two errors that the winres.h file is missing there. To do this, go to the location of the error, rename it winresrc.h and create it again. Now it will be built, and you can use sqlite in your project.
    1. To use the .js SQLite3JS file, specify the src of the js file, such as SQLite3JS \ js \ SQLite3.js, on the html page where you intend to use sqlite. Here I give you an example of using sqlite in js // This will create the db.sqlite database name and try to create the Name Notes table. 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, TEXT notes))); I hope that all these steps will help you.
+1
source

All Articles