Giter Site home page Giter Site logo

wills01 / sqlite Goto Github PK

View Code? Open in Web Editor NEW

This project forked from capacitor-community/sqlite

0.0 0.0 0.0 32.82 MB

Community plugin for native & electron SQLite databases

License: MIT License

JavaScript 0.12% Ruby 0.10% Objective-C 0.35% Java 33.05% TypeScript 25.21% Swift 41.17%

sqlite's Introduction


SQLITE DATABASE

@capacitor-community/sqlite


CAPACITOR 6



Note from the Owner


Start -->


I have been dedicated to developing and maintaining this plugin for many years since the inception of Ionic Capacitor. Now, at 73+ years old, and with my MacBook Pro becoming obsolete for running Capacitor 6 for iOS, I have made the decision to cease maintenance of the plugin. If anyone wishes to take ownership of this plugin, they are welcome to do so.


It has been a great honor to be part of this development journey alongside the developer community. I am grateful to see many of you following me on this path and incorporating the plugin into your applications. Your comments and suggestions have motivated me to continuously improve it.


I have made this decision due to several family-related troubles that require my full attention and time. Therefore, I will not be stepping back. Thank you to all of you for your support.


End <--


Capacitor community plugin for Native and Electron SQLite Databases. - In Native, databases could be encrypted with `SQLCipher` - In Electron, databases could be encrypted with `better-sqlite3-multiple-ciphers`



Maintainers

Maintainer GitHub Social
Quéau Jean Pierre jepiqueau

To install:

npm install --save @capacitor-community/sqlite
npx cap sync
yarn add @capacitor-community/sqlite
npx cap sync
pnpm install --save @capacitor-community/sqlite
pnpm install --save @jeep-sqlite
pnpm install --save sql.js
npx cap sync

then add plugin to main capacitor.config.ts file:

import { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
  appId: 'com.jeep.app.ionic7.angular.sqlite',
  appName: 'ionic7-angular-sqlite-starter',
  webDir: 'www',
  server: {
    androidScheme: 'https'
  },
  plugins: {
    CapacitorSQLite: {
      iosDatabaseLocation: 'Library/CapacitorDatabase',
      iosIsEncryption: true,
      iosKeychainPrefix: 'angular-sqlite-app-starter',
      iosBiometric: {
        biometricAuth: false,
        biometricTitle : "Biometric login for capacitor sqlite"
      },
      androidIsEncryption: true,
      androidBiometric: {
        biometricAuth : false,
        biometricTitle : "Biometric login for capacitor sqlite",
        biometricSubTitle : "Log in using your biometric"
      },
      electronIsEncryption: true,
      electronWindowsLocation: "C:\\ProgramData\\CapacitorDatabases",
      electronMacLocation: "/Volumes/Development_Lacie/Development/Databases",
      electronLinuxLocation: "Databases"
    }
  }
};
export default config;

More Reading:

Tutorials Blog

Web Quirks

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. You'll need the usual capacitor/android/react npm script to build and copy the assets folder.

For Angular framework

  • Copy manually the file sql-wasm.wasm from node_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 node_modules/sql.js/dist/sql-wasm.wasm to the public/assets folder of YOUR_APP

Android Quirks

  • In case you get the following error when building your app in Android Studio: x files found with path 'build-data.properties'. You can you add the following code to app/build.gradle:
    packagingOptions {
        exclude 'build-data.properties'
    }

See #301 and SO question for more information.

  • Check/Add the following: Gradle JDK version 17 Android Gradle Plugin Version 8.0.0 In variables.gradle

    minSdkVersion = 22
    compileSdkVersion = 33
    targetSdkVersion = 33
    

    In AndroidManifest.xml

        <application
          android:allowBackup="false"
          android:fullBackupContent="false"
          android:dataExtractionRules="@xml/data_extraction_rules"
    

    In res/xml create a file data_extraction_rules.xml containing:

    <?xml version="1.0" encoding="utf-8"?>
    <data-extraction-rules>
        <cloud-backup>
          <exclude domain="root" />
          <exclude domain="database" />
          <exclude domain="sharedpref" />
          <exclude domain="external" />
        </cloud-backup>
        <device-transfer>
          <exclude domain="root" />
          <exclude domain="database" />
          <exclude domain="sharedpref" />
          <exclude domain="external" />
        </device-transfer>
    </data-extraction-rules>
    

Electron Quirks

  • On Electron, go to the Electron folder of YOUR_APPLICATION
cd electron
npm install --save better-sqlite3-multiple-ciphers
npm install --save electron-json-storage
npm install --save jszip
npm install --save [email protected]
npm install --save crypto
npm install --save crypto-js
npm install --save-dev @types/better-sqlite3
npm install --save-dev @types/electron-json-storage
npm install --save-dev @types/crypto-js
  • Important: node-fetch version must be <=2.6.7; otherwise you'll get an error running the app.

  • Important: if you are using @capacitor-community/electron v5

npm install --save-dev [email protected]
npm uninstall --save-dev electron-rebuild
npm install --save-dev @electron/rebuild
npm install --save-dev [email protected]
  • in electron folder open the tsconfig.json file and add "skipLibCheck": true,

IOS Quirks

  • on iOS, no further steps needed.

Supported Methods by Platform

Name Android iOS Electron Web
createConnection (ReadWrite)
createConnection (ReadOnly)
closeConnection (ReadWrite)
closeConnection (ReadOnly)
isConnection (ReadWrite)
isConnection (ReadOnly)
open (non-encrypted DB)
open (encrypted DB)
close
getUrl
getVersion
execute
executeSet
run
query
deleteDatabase
importFromJson
exportToJson
deleteExportedRows
createSyncTable
setSyncDate
getSyncDate
isJsonValid
isDBExists
addUpgradeStatement
copyFromAssets
isDBOpen
isDatabase
isTableExists
getTableList
getDatabaseList
getMigratableDbList
addSQLiteSuffix
deleteOldDatabases
moveDatabasesAndAddSuffix
checkConnectionsConsistency
isSecretStored
setEncryptionSecret
changeEncryptionSecret
clearEncryptionSecret
checkEncryptionSecret
initWebStore
saveToStore
getNCDatabasePath
createNCConnection
closeNCConnection
isNCDatabase
transaction
getFromHTTPRequest
isDatabaseEncrypted
isInConfigEncryption
isInConfigBiometricAuth
getFromLocalDiskToStore
saveToLocalDisk
beginTransaction
commitTransaction
rollbackTransaction
isTransactionActive

Documentation & APIs

Applications demonstrating the use of the plugin and related documentation

Ionic/Angular

Ionic/Angular TypeORM app (Not Updated)

Ionic/React

Ionic/React Capacitor SQLite + TypeORM Example App

Ionic/Vue

Vue (Not Updated)

Vue TypeORM app (Not Updated)

SolidJS+Vite (Not Updated)

Nuxt3 + Kysely

Quasar

SvelteKit

Dependencies

The iOS and Android codes are using SQLCipher allowing for database encryption. The iOS codes is using ZIPFoundation for unzipping assets files The Electron code is using better-sqlite3-multiple-ciphers , electron-json-storage and node-fetch from 5.0.4. The Web code is using the Stencil component jeep-sqlite based on sql.js, localforage. and jszip

Contributors ✨

Thanks goes to these wonderful people (emoji key):

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

sqlite's People

Contributors

jepiqueau avatar dragermrb avatar tobiasmuecksch avatar harelm avatar dependabot[bot] avatar chriswep avatar mhartington avatar gion-andri avatar cosentino avatar folsze avatar victorybiz avatar rdlabo avatar muuvmuuv avatar joewoodhouse avatar saintpepsi avatar ws-rush avatar ptasheq avatar rubickecho avatar paulantoine2 avatar mmouterde avatar jonz94 avatar iamcco avatar fizdalf avatar digaus avatar aeinn avatar lovetodream avatar thenovemberrain avatar pranav-singhal avatar patdx avatar oscarfonts 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.