GithubHelp home page GithubHelp logo

pke / sqlite3-winrt Goto Github PK

View Code? Open in Web Editor NEW

This project forked from doo/sqlite3-winrt

0.0 2.0 0.0 3.77 MB

SQLite3 WinRT Component

License: MIT License

C++ 0.56% C 93.16% JavaScript 6.14% HTML 0.02% CSS 0.11%
winrt windows sqlite3

sqlite3-winrt's Introduction

SQLite3-WinRT

Async SQLite for (JavaScript) Windows Store apps.

Changelog

1.3.4

Support for blobs

This allows you to insert blobs into your database and read them back as BASE64 encoded values in your JSON result. See the blob example how to use it in your apps. If you need an IBuffer back from the db you can use CryptographicBuffer.DecodeFromBase64String.

1.1.2

Some minor API changes:

  1. getLastInsertRowId() function becomes lastInsertRowId property
  2. getAutocommit() function becomes autoCommit property
  3. getLastError() function becomes lastError property
  4. enableSharedCache() function becomes sharedCache property

1.1.0

This version introduces a breaking API change along with some enhancements:

  1. runAsync no longer returns the database for chained calls. Instead it will now return the number of rows affected by the executed SQL statement.
  2. A special collation sequence, WINLOCALE is introduced. It uses the sorting behaviour of the currently active system locale. The locale can be overridden by setting db.collationLanguage.
  3. We also now implemented a regexp function based on the STL (TR1) regex functionality. You can now use the REGEXP operator, see the SQLite documentation for further information.

As usual, you should look at our unit tests if you are unsure how to use this new functionality.

Status

We finally consider SQLite3-WinRT ready for production use and it is already being used by certified apps published in the Windows Store including, of course our own application. Support for BLOBs and an API for transaction management are still on our to-do list - unfortunately with a very low priority. Feedback and contributions are highly appreciated, feel free to open issues or pull requests on GitHub.

Setup

SQLite3-WinRT consists of two parts, a WinRT component named SQLite3Component and a JavaScript namespace called SQLite3JS that builds upon the SQLite3Component.

Therefore, in order to use SQLite3JS in a JavaScript app, the SQLite3Component project SQLite3Component\SQLite3Component.vcxproj must be added to the app's solution using FILE > Add > Existing Project.... A reference to SQLite3Component must be added to the app's project using PROJECT > Add Reference.... Now, the SQLite3JS source SQLite3JS\js\SQLite3.js can be used in the app's project.

Note for users of Visual Studio 2012 Express: To compile the WinRT component successfully, please install the Windows SDK.

Usage

The SQLite3JS namespace provides an async JavaScript API for SQLite. It is built around the Database object that can be obtained using SQLite3JS.openAsync(). The API was inspired by node-sqlite3.

Example

var dbPath = Windows.Storage.ApplicationData.current.localFolder.path + '\\db.sqlite';
SQLite3JS.openAsync(dbPath)
.then(function (db) {
  return db.runAsync('CREATE TABLE Item (name TEXT, price REAL, id INT PRIMARY KEY)')
  .then(function () {
    return db.runAsync('INSERT INTO Item (name, price, id) VALUES (?, ?, ?)', ['Mango', 4.6, 123]);
  })
  .then(function () {
    return db.eachAsync('SELECT * FROM Item', function (row) {
      console.log('Get a ' + row.name + ' for $' + row.price);
    });
  })
  .then(function () {
    db.close();
  });
});

License

Copyright (c) 2012,2013 doo GmbH

Licensed under the MIT License, see LICENSE file.

sqlite3-winrt's People

Contributors

superquadratic avatar pke avatar milgner avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.