micheal-w-wells / sqlite

Community plugin for native & electron SQLite databases

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


SQLITE DATABASE

@capacitor-community/sqlite


CAPACITOR 3


Capacitor community plugin for Native and Electron SQLite Databases. In Native databases could be encrypted with SQLCipher



Maintainers

Maintainer GitHub Social
QuΓ©au Jean Pierre jepiqueau

CAPACITOR 3 (Master)

🚨 !!! Sorry for Electron developper, they will have to wait for @capacitor-community/electron release 4 before getting the @capacitor-community/sqlite Electron plugin part !!! 🚨

🚨 Since release 3.1.2 ->> 🚨

Thanks to Nirajhinge and Chris, an example of using the TypeORM driver in a Ionic/Vue app has been developed see https://github.com/jepiqueau/vue-typeorm-app.

🚨 Since release 3.0.0-rc.2 ->> 🚨

Thanks to Chris, a driver to TypeORM is now available

🚨 Since release 3.0.0-beta.13 ->> 🚨

  • GlobalSQLite secret and newsecret are deprecated

  • The user can now set its own secure secret (passphrase)

    • use setEncryptionSecret ONCE to migrate encrypted databases from secret to secure stored secret

    • use changeEncryptionSecret to change your secure stored secret

  • iOS used KeyChain service to store the secret

  • Android used Encrypted SharedPreferences to store the secret, the minimun sdk should be set to 23 (limitation from Google)

🚨 Since release 3.0.0-beta.13 ->> 🚨

🚨 Since release 3.0.0-beta.11 ->> 🚨

  • Checking of types has been removed in all methods of the plugin both iOS & Android. This has been achieved to allow the use of others RDBMS types. The type checking is now under the responsability of the developers.

  • NULL values are now returned as null

  • values for the query method is now an Array of any.

  • option to disable transaction for the execute, executeSet, run.

🚨 Since release 3.0.0-beta.11 <<- 🚨

The test has been achieved on:

REFACTOR (Move to branch 2.9.x)

The 2.9.x is now πŸ›‘ NOT MAINTAINED ANYMORE πŸ›‘.

The refactor offers now (since 2.9.0-beta.1) all the features that the previous was offering. It has been a quite heavy process, hoping that the developpers will take benefit from it.

The main reasons for it:

  • multiple database connections
  • db connector allowing for easy commands db.open(), db.close, ...
  • improve the response time of the encrypted database by removing the internal open and close database for each sqlite query
  • moving to the latest androidx.sqlite.db.xxx
  • offering encryption for Electron platform by using @journeyapps/sqlcipher on MacOs, !!! NOT ON WINDOWS !!!
  • cleaning and aligning the code between platforms
  • allowing developers to develop typeorm or spatialite drivers.

This was discussed lengthly in issue#1 and issue#52

Refactor available for Android, iOS and Electron platforms.

The test has been achieved on:

Other frameworks will be tested later

  • Stencil

@INITIAL πŸ›‘ (Move to branch 2.4.x)

The 2.4.x is now πŸ›‘ NOT MAINTAINED ANYMORE πŸ›‘.

To install it

npm i --save @capacitor-community/sqlite@initial

The test has been achieved on:

Browser Support

The plugin follows the guidelines from the Capacitor Team,

meaning that it will not work in IE11 without additional JavaScript transformations, e.g. with Babel.

Installation

npm install @capacitor-community/sqlite
npm run build
npx cap sync
npx cap add android
npx cap add ios
// npx cap add @capacitor-community/electron not working

IOS

  • on iOS, no further steps needed.

Android

  • On Android, no further steps needed.

Electron 🚧 (NOT WORKING YET)

  • On Electron, go to the Electron folder of YOUR_APPLICATION

Build & Run

npm run build
npx cap copy

IOS

npx cap open ios

Android

npx cap open android

Electron 🚧 (NOT WORKING YET)

npx cap open @capacitor-community/electron

Issues

issues

Configuration

No configuration required for this plugin

Supported methods

Name Android iOS Electron Mac Electron Windows Web
createConnection βœ… βœ… 🚧 🚧 ❌
closeConnection βœ… βœ… 🚧 🚧 ❌
isConnection βœ… βœ… 🚧 🚧 ❌
open (non-encrypted DB) βœ… βœ… 🚧 🚧 ❌
open (encrypted DB) βœ… βœ… 🚧 🚧 ❌
close βœ… βœ… 🚧 🚧 ❌
execute βœ… βœ… 🚧 🚧 ❌
executeSet βœ… βœ… 🚧 🚧 ❌
run βœ… βœ… 🚧 🚧 ❌
query βœ… βœ… 🚧 🚧 ❌
deleteDatabase βœ… βœ… 🚧 🚧 ❌
importFromJson βœ… βœ… 🚧 🚧 ❌
exportToJson βœ… βœ… 🚧 🚧 ❌
createSyncTable βœ… βœ… 🚧 🚧 ❌
setSyncDate βœ… βœ… 🚧 🚧 ❌
getSyncDate βœ… βœ… 🚧 🚧 ❌
isJsonValid βœ… βœ… 🚧 🚧 ❌
isDBExists βœ… βœ… 🚧 🚧 ❌
addUpgradeStatement βœ… βœ… 🚧 🚧 ❌
copyFromAssets βœ… βœ… 🚧 🚧 ❌
isDBOpen βœ… βœ… 🚧 🚧 ❌
isDatabase βœ… βœ… 🚧 🚧 ❌
isTableExists βœ… βœ… 🚧 🚧 ❌
getDatabaseList βœ… βœ… 🚧 🚧 ❌
addSQLiteSuffix βœ… βœ… 🚧 🚧 ❌
deleteOldDatabases βœ… βœ… 🚧 🚧 ❌
checkConnectionsConsistency βœ… βœ… 🚧 🚧 ❌
isSecretStored βœ… βœ… 🚧 🚧 ❌
setEncryptionSecret βœ… βœ… 🚧 🚧 ❌
changeEncryptionSecret βœ… βœ… 🚧 🚧 ❌

Supported SQLite Types

-Datatypes In SQLite Version 3

Documentation

API

Framework's Usage

Applications demonstrating the use of the plugin

Ionic/Angular

Ionic/React (to come later)

Ionic/Vue (to come later)

Vue (to come later)

Usage

Dependencies

The IOS and Android codes are using SQLCipher allowing for database encryption

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Jean Pierre QuΓ©au

πŸ’»

Paul Antoine

πŸ’»

Karyfars

πŸ’»

Chriswep

πŸ“–

Nirajhinge

πŸ’»

This project follows the all-contributors specification. Contributions of any kind welcome!

About

Community plugin for native & electron SQLite databases

License:MIT License


Languages

Language:Swift 49.0%Language:Java 41.5%Language:TypeScript 8.6%Language:Objective-C 0.5%Language:Ruby 0.2%Language:JavaScript 0.2%