You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@tobiasmuecksch
Query is for select statement
Execute is for executing a set of raw statement given in a string.
Run is for executing one raw statement Insert, Update, Delete with given values meaning that you prépare the statement and bind the values if any
ExecuteSet is to run on or more raw statements and bind them with values or an array of values .
Hope this clarify
@tobiasmuecksch i just issue a new Ionic/Angular app demonstrating how to use the @capacitor-community/sqlite plugin to synchronize with a remote server database by using the import & export of Json Object. The deleted rows are now well managed. Look at angular-sqlite-synchronize-app, hope this will clarify
@rakibul111
Npm i -- save @capacitor/core
Npm i --save-dev @capacitor/cli
Npm i --save @capacitor/ios and Android
Npx cap init yourappname yourappid
Npm run build
Npx cap add ios
Npx cap add android
Npx cap sync
Npm run build
Npx cap copy
Npx cap open ios
Npx cap open android
Thatis it
@jepiqueau Uncaught (in promise) RuntimeError: Aborted(LinkError: WebAssembly.instantiate(): Import #33 module="a" function="I" error: function import requires a callable). Build with -s ASSERTIONS=1 for more info.
at L (jeep-sqlite.entry.js:2591:71)
at jeep-sqlite.entry.js:2641:387
@rakibul111 as mentioned by @tobiasmuecksch this is not the right place. Any how delete the sql-wasm.wasm file from your assets folder and copy the one from the node_modules/sql.js/dist/sql_wasm.wasm to your asset folder this should solve the issue
I'm just starting with this sqlite plugin, I hope this will be relevant.
My point is about the IncrementalUpgrade feature documentation.
The main readme.md shows a broken link
the page IncrementalUpgradeDatabaseVersion is really clear about the proposal, but less about the final implementation. Is there an example somewhere else ?
The page UpgradeDatabaseVersion seems more relative to the implementation but mentions an openDB function I can't found.
During my tests on web platform my addUpgradeStatement does not throw error, but has no effect ?! As well as with an empty database as with an existing version.
This tuto is not really easy to follow as the final workflow is split into several services.
Anyway, that a great, complete and verbose work that helps me. thanks @jepiqueau !
If it could help someone, Here is my working resulting version in a single file src/services/databaseService. databaseService.init() is simply called from App.vue.
Tested with Quasar+vue3+vite+capacitor (web+android)
import{Platform}from'quasar';import{CapacitorSQLite,SQLiteConnection,SQLiteDBConnection}from'@capacitor-community/sqlite';import{version1}from'src/migrations/version1';import{JeepSqlite}from'jeep-sqlite/dist/components/jeep-sqlite';constDATABASE_NAME='db_name'constDATABASE_CURRENT_VERSION=1;constsqlite: SQLiteConnection=newSQLiteConnection(CapacitorSQLite);exportasyncfunctioninit(){customElements.define('jeep-sqlite',JeepSqlite);window.addEventListener('DOMContentLoaded',async()=>{try{if(!Platform.is.capacitor){constjeepSqlite=document.createElement('jeep-sqlite');document.body.appendChild(jeepSqlite);awaitcustomElements.whenDefined('jeep-sqlite');awaitsqlite.initWebStore();}awaitCapacitorSQLite.addUpgradeStatement({database: DATABASE_NAME,upgrade: [version1]});constret=awaitsqlite.checkConnectionsConsistency();constisConn=(awaitsqlite.isConnection(DATABASE_NAME,false)).result;
let db: SQLiteDBConnection;if(ret.result&&isConn){db=awaitsqlite.retrieveConnection(DATABASE_NAME,false);}else{db=awaitsqlite.createConnection(DATABASE_NAME,false,'no-encryption',DATABASE_CURRENT_VERSION,false,);}awaitdb.open();}catch(err){console.log(`Error: ${err}`);thrownewError(`Error: ${err}`);}});}
To going back to the goal of this issue, I guess IncrementalUpgrade part is still confusing as :
openDB function does not exists.
"It has to be called prior to open the database with the new version number" => not only prior to open but also even prior checkConnectionsConsistency
According to my recent experience the Vue Usage part as described here is not working. According to @jepiqueau tutorial, jeep-sqlite/loader seems not relevant any more ?!
@mmouterde Sorry the documentation has not been updated. i focus my attention in providing tutorials. look at link to tuorials and specifically for vue3 at Vue3-Web and Vue3-Native. These tutorials are based on the latest version of Ionic7 and are using Vue with Vite. The upgrade statement must be defined prior to any connection to the database and are read and implemented when you make the connection to the database with the desired version number. This should help you to start.
@mmouterde What is important is to define the service as unique throughout your application and i do not know how to do that with Quasar as the App.Vue i s something like this
And then configure boot scripts option in quasar.config.js :
boot: ['i18n','axios','sqlite'/*<=*/],
According to my tests, the DOMContentLoaded event has already occurred when boot scripts run. I had to remove the window.addEventListener('DOMContentLoaded',...) from my previous init() implementation :
<template><router-view/></template><scriptlang="ts">import{defineComponent,createApp,onMounted}from'vue';import{Capacitor}from'@capacitor/core';import{JeepSqlite}from'jeep-sqlite/dist/components/jeep-sqlite';importSqliteServicefrom'./services/sqliteService';importDbVersionServicefrom'./services/dbVersionService';importStorageServicefrom'./services/storageService';importInitializeAppServicefrom'./services/initializeAppService';exportdefaultdefineComponent({name: 'App',setup(){customElements.define('jeep-sqlite',JeepSqlite);constapp=createApp({});constplatform=Capacitor.getPlatform();// Set the platform as global properties on the appapp.config.globalProperties.$platform=platform;console.log('platform',app.config.globalProperties.$platform);// Define and instantiate the required servicesconstsqliteServ=newSqliteService();constdbVersionServ=newDbVersionService();conststorageServ=newStorageService(sqliteServ,dbVersionServ);// Set the services as global properties on the appapp.config.globalProperties.$sqliteServ=sqliteServ;app.config.globalProperties.$dbVersionServ=dbVersionServ;app.config.globalProperties.$storageServ=storageServ;//Define and instantiate the InitializeAppServiceconstinitAppServ=newInitializeAppService(sqliteServ,storageServ);constinitApp=async()=>{try{awaitinitAppServ.initializeApp();}catch(error){console.error('App Initialization error:',error);}};onMounted(async()=>{if(platform!='web'){awaitinitApp();}else{window.addEventListener('DOMContentLoaded',async()=>{constjeepEl=document.createElement('jeep-sqlite');document.body.appendChild(jeepEl);customElements.whenDefined('jeep-sqlite').then(async()=>{awaitinitApp();}).catch((err)=>{console.error('jeep-sqlite creation error:',err);});});}});return{};},});</script>
the services are the same than in ionic7-vue-sqlite-app, the models and the upgrades are also the same
@tobiasmuecksch and all coming to that issue on documentation
To all, I know that the documentation is not up-to-date and part of it will be removed soon as it is difficult to maintain as Capacitor, the plugin and the Frameworks are continuously updated.
So i will advise you to visit tutorials which are all compatible with Capacitor 5, Ionic 7 and @capacitor-community/sqlite@5.4.x. If some of you want to see others features, feel free to mention them or to participate in that effort, by creating new tutorials.
This thread is from 2022 and mixes many topics. Several points are done and others are outdated, so I am closing it. A single doc topic is easier to track in its own issue.
Activity
tobiasvorhoff commentedon Apr 17, 2022
Issues to consider for information gathering:
npx cap sync @capacitor-community/electronbreaks configuration #255deleteDatabase()does not work #247.createConnection()"Not implemented on web" #244TypeError: Cannot read properties of undefined (reading 'CapacitorSQLite')#242tobiasvorhoff commentedon Apr 17, 2022
@jepiqueau Could you give me some explanation for this question?
[-]Documentation improvements[/-][+]Documentation improvements collection[/+]jepiqueau commentedon Apr 18, 2022
@tobiasmuecksch
Query is for select statement
Execute is for executing a set of raw statement given in a string.
Run is for executing one raw statement Insert, Update, Delete with given values meaning that you prépare the statement and bind the values if any
ExecuteSet is to run on or more raw statements and bind them with values or an array of values .
Hope this clarify
jepiqueau commentedon Apr 18, 2022
@tobiasmuecksch on Electron you do not need to use saveToStore. This is only for the Web platform
tobiasvorhoff commentedon Apr 18, 2022
My bad. I fixed the issue description.
jepiqueau commentedon May 5, 2022
@tobiasmuecksch i just issue a new Ionic/Angular app demonstrating how to use the @capacitor-community/sqlite plugin to synchronize with a remote server database by using the import & export of Json Object. The deleted rows are now well managed. Look at angular-sqlite-synchronize-app, hope this will clarify
rakibul111 commentedon Aug 17, 2022
@jepiqueau can you please guide me how can I use this sqlite plugin with nextjs-ionic setup.
Note: I don't know typescript
jepiqueau commentedon Aug 17, 2022
@rakibul111 exactely the same way that for react, vue, solidjs or angular.
jepiqueau commentedon Aug 17, 2022
@rakibul111
Npm i -- save @capacitor/core
Npm i --save-dev @capacitor/cli
Npm i --save @capacitor/ios and Android
Npx cap init yourappname yourappid
Npm run build
Npx cap add ios
Npx cap add android
Npx cap sync
Npm run build
Npx cap copy
Npx cap open ios
Npx cap open android
Thatis it
rakibul111 commentedon Aug 17, 2022
@jepiqueau where to setup for jeep-sqlite?
rakibul111 commentedon Aug 17, 2022
@jepiqueau Uncaught (in promise) RuntimeError: Aborted(LinkError: WebAssembly.instantiate(): Import #33 module="a" function="I" error: function import requires a callable). Build with -s ASSERTIONS=1 for more info.
at L (jeep-sqlite.entry.js:2591:71)
at jeep-sqlite.entry.js:2641:387
tobiasvorhoff commentedon Aug 17, 2022
This is not the right issue for this discussion.
Please open a new issue for that.
jepiqueau commentedon Aug 18, 2022
@rakibul111 as mentioned by @tobiasmuecksch this is not the right place. Any how delete the sql-wasm.wasm file from your assets folder and copy the one from the node_modules/sql.js/dist/sql_wasm.wasm to your asset folder this should solve the issue
jhuenges commentedon Mar 10, 2023
I also have a suggestion for the documentation:
What happens if the user deletes the app?
Were is the database stored on the phone?
@jepiqueau If you can answer these questions, I can create a pull request to add this information.
4 remaining items
jepiqueau commentedon Jul 17, 2023
@mburger81 A documentation has been added DatabaseEncryption. Hope this will help you to understand the workflow
mmouterde commentedon Nov 8, 2023
I'm just starting with this sqlite plugin, I hope this will be relevant.
My point is about the IncrementalUpgrade feature documentation.
openDBfunction I can't found.During my tests on web platform my
addUpgradeStatementdoes not throw error, but has no effect ?! As well as with an empty database as with an existing version.jepiqueau commentedon Nov 14, 2023
@mmouterde look at ionic7-angular-sqlite-app and at the blog tutorials-app at https://github.com/jepiqueau
mmouterde commentedon Nov 16, 2023
This tuto is not really easy to follow as the final workflow is split into several services.
Anyway, that a great, complete and verbose work that helps me. thanks @jepiqueau !
If it could help someone, Here is my working resulting version in a single file
src/services/databaseService.databaseService.init()is simply called fromApp.vue.Tested with Quasar+vue3+vite+capacitor (web+android)
To going back to the goal of this issue, I guess IncrementalUpgrade part is still confusing as :
openDBfunction does not exists.checkConnectionsConsistencyjeep-sqlite/loaderseems not relevant any more ?!jepiqueau commentedon Nov 20, 2023
@mmouterde Sorry the documentation has not been updated. i focus my attention in providing tutorials. look at link to tuorials and specifically for vue3 at Vue3-Web and Vue3-Native. These tutorials are based on the latest version of Ionic7 and are using Vue with Vite. The upgrade statement must be defined prior to any connection to the database and are read and implemented when you make the connection to the database with the desired version number. This should help you to start.
jepiqueau commentedon Nov 20, 2023
@mmouterde What is important is to define the service as unique throughout your application and i do not know how to do that with Quasar as the App.Vue i s something like this
so if i define a setup method i cannot use this.
mmouterde commentedon Nov 20, 2023
Hum, ok, in this case it would be better to use
boot fileshook from Quasar.from
src/boot/sqlite.tsAnd then configure boot scripts option in
quasar.config.js:According to my tests, the
DOMContentLoadedevent has already occurred when boot scripts run. I had to remove thewindow.addEventListener('DOMContentLoaded',...)from my previousinit()implementation :jepiqueau commentedon Nov 20, 2023
@mmouterde In fact i did this and it works
the services are the same than in ionic7-vue-sqlite-app, the models and the upgrades are also the same
jepiqueau commentedon Nov 20, 2023
@mmouterde you can remove the line
window.addEventListener('DOMContentLoaded', async () => {as it is done in the onMounted method it is working toojepiqueau commentedon Nov 28, 2023
@mmouterde look at quasar-sqlite-app, For now only the web part is in the tutorial the native part will come next . Hope this will help you
jepiqueau commentedon Nov 28, 2023
@tobiasmuecksch and all coming to that issue on documentation
To all, I know that the documentation is not up-to-date and part of it will be removed soon as it is difficult to maintain as Capacitor, the plugin and the Frameworks are continuously updated.
So i will advise you to visit tutorials which are all compatible with Capacitor 5, Ionic 7 and @capacitor-community/sqlite@5.4.x. If some of you want to see others features, feel free to mention them or to participate in that effort, by creating new tutorials.
robingenz commentedon Nov 25, 2026
This thread is from 2022 and mixes many topics. Several points are done and others are outdated, so I am closing it. A single doc topic is easier to track in its own issue.