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)
π¨ Since release 3.2.0-5 ->> π¨
The Web plugin is now implemented based on the stencil companion jeep-sqlite@0.0.7
which is using sql.js@1.5.0
for database queries and localeforage@1.9.0
for database persistency.
π¨ Since release 3.2.0-3 ->> π¨
The Electron plugin is now based on @capacitor-community/electron@4.0.3
thanks to the hard and heavy work from Mike Summerfeldt IT-MikeS
π π
π¨ Since release 3.2.0-2 ->> π¨
π¨ !!! for Electron developper, the Electron plugin is back !!! π¨
Based on sqlite3
, so without encryption
The two listeners sqliteImportProgressEvent
and sqliteExportProgressEvent
are not available.
π¨ 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)
-
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
@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 add android
npx cap add ios
npx cap add @capacitor-community/electron
and do when you update
npx cap sync
npx cap sync @capacitor-community/electron
Web
For Angular framework
- copy manually the file
sql-wasm.wasm
from nodes_modules/sql.js/dist/sql-wasm.wasm
to the src/assets
folder of YOUR_APP
For Vue & React frameworks
- copy manually the file
sql-wasm.wasm
from nodes_modules/sql.js/dist/sql-wasm.wasm
to the public/assets
folder of YOUR_APP
IOS
- on iOS, no further steps needed.
Android
- On Android, no further steps needed.
Electron
- On Electron, go to the Electron folder of YOUR_APPLICATION
cd electron
npm install --save sqlite3
npm install --save-dev @types/sqlite3
npm run build
Build & Run
npm run build
npx cap copy
npx cap copy web
npx cap copy @capacitor-community/electron
Web
ionic serve
npm run serve
npm run start
IOS
npx cap open ios
Android
npx cap open android
Electron
npx cap open @capacitor-community/electron
Issues
issues
Configuration
No configuration required for this plugin
Supported methods
Name | Android | iOS | Electron | Web |
---|
createConnection | β
| β
| β
| β
|
closeConnection | β
| β
| β
| β
|
isConnection | β
| β
| β
| β
|
open (non-encrypted DB) | β
| β
| β
| β
|
open (encrypted DB) | β
| β
| β | β |
close | β
| β
| β
| β
|
getVersion | β
| β
| β
| β
|
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
Ionic/Vue
Vue
Usage
Dependencies
The IOS and Android codes are using SQLCipher
allowing for database encryption.
The Electron code is using sqlite3
.
The Web code is using the Stencil component jeep-sqlite
based on sql.js
and localforage
.
Contributors β¨
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!