# I'm just starting and taking some hard hits with SQLite Capacitor

**URL:** <https://forum.ionicframework.com/t/im-just-starting-and-taking-some-hard-hits-with-sqlite-capacitor/240536>\
**Category:** Capacitor\
**Created:** [March 26, 2024, 1:32pm UTC](https://forum.ionicframework.com/t/im-just-starting-and-taking-some-hard-hits-with-sqlite-capacitor/240536 "2024-03-26T13:32:04Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amarinhu](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/amarinhu/32/146984_2.png) [@Amarinhu](https://forum.ionicframework.com/u/Amarinhu)\
**Post date:** [March 26, 2024, 1:32pm UTC](https://forum.ionicframework.com/t/im-just-starting-and-taking-some-hard-hits-with-sqlite-capacitor/240536/1 "2024-03-26T13:32:04Z")

</div>

I’m currently developing an Ionic 7 React application using Capacitor and attempting to integrate SQLite. However, I’m encountering difficulties getting SQLite to function properly. I’ve been working on this for several days now, and it’s proving to be quite challenging.

Could someone please provide an example app demonstrating CRUD operations with Ionic 7 React and SQLite? Alternatively, if there’s a comprehensive guide available, I’d greatly appreciate it. Initially, I considered using Ionic Storage, but I’m unsure if a Key-Value approach is suitable for my requirements (though I’m open to suggestions if anyone has nice ideas on its usage).

To provide some context for my application, I’m developing an Ionic app for mobile platforms (Android and iOS) that interacts with an API containing a substantial database. I need to store JSON data for students, classes, teachers, observations, reports, etc. The intention is to store only the data from the last month locally, with regular deletion of older data (requiring an internet connection for accessing older data). Additionally, the app needs to support various filters allowing users to filter by class date, school, discipline, students, etc.

Furthermore, if a user logs in with a different account, the local database should be cleared and replaced with data corresponding to the new user.

---

<div class="post-metadata">

**Author:** ![twestrick](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/twestrick/32/136131_2.png) [@twestrick](https://forum.ionicframework.com/u/twestrick)\
**Post date:** [March 26, 2024, 8:29pm UTC](https://forum.ionicframework.com/t/im-just-starting-and-taking-some-hard-hits-with-sqlite-capacitor/240536/2 "2024-03-26T20:29:12Z")

</div>

Are you using the Community SQLite plugin? - [GitHub - capacitor-community/sqlite: Community plugin for native & electron SQLite databases](https://github.com/capacitor-community/sqlite)

How much data are we talking that you need to store? My app is currently using 1.85 MB of storage using Ionic Storage. Each key is a “table” and value is an encoded JSON string of all the records. On app load, all the data gets loaded into memory in my Pinia store in Vue. I know that isn’t much storage use, but at that, the app still loads really fast.

---

<div class="post-metadata">

**Author:** ![Amarinhu](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/amarinhu/32/146984_2.png) [@Amarinhu](https://forum.ionicframework.com/u/Amarinhu)\
**Post date:** [March 27, 2024, 12:58pm UTC](https://forum.ionicframework.com/t/im-just-starting-and-taking-some-hard-hits-with-sqlite-capacitor/240536/3 "2024-03-27T12:58:38Z")

</div>

Thanks for the answering. So, i’m doing some estimates here and it actually might be around 3 MBs, lower than i expected.  
I’m actually managing to make SQLite to work, but now you gave me a quite good idea indeed.

---

<div class="post-metadata">

**Author:** ![Amarinhu](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/amarinhu/32/146984_2.png) [@Amarinhu](https://forum.ionicframework.com/u/Amarinhu)\
**Post date:** [March 27, 2024, 1:14pm UTC](https://forum.ionicframework.com/t/im-just-starting-and-taking-some-hard-hits-with-sqlite-capacitor/240536/4 "2024-03-27T13:14:00Z")

</div>

The only thing that i’ll have to figure out is how do i make it synchronizing with the server. The idea is that only data that was edited would be sent from the app to the server and from the server to the app checking a key in the json named "Sync: " that can be “true” or “false”.

---

<div class="post-metadata">

**Author:** ![twestrick](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/twestrick/32/136131_2.png) [@twestrick](https://forum.ionicframework.com/u/twestrick)\
**Post date:** [March 27, 2024, 1:37pm UTC](https://forum.ionicframework.com/t/im-just-starting-and-taking-some-hard-hits-with-sqlite-capacitor/240536/5 "2024-03-27T13:37:57Z")

</div>

I know there are some DBs out there that help with that. They have been discussed in this forum previously by others but I don’t recall what they are.

---

<div class="post-metadata">

**Author:** ![Amarinhu](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/amarinhu/32/146984_2.png) [@Amarinhu](https://forum.ionicframework.com/u/Amarinhu)\
**Post date:** [March 27, 2024, 1:45pm UTC](https://forum.ionicframework.com/t/im-just-starting-and-taking-some-hard-hits-with-sqlite-capacitor/240536/6 "2024-03-27T13:45:16Z")

</div>

I’ll keep searching, i saw Rxdb, but as i didn’t find a significant community around it, i prefered to stay away from it.

Maybe pouchDB could be an option?

Again, thx for answering.

---

<div class="post-metadata">

**Author:** ![twestrick](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/twestrick/32/136131_2.png) [@twestrick](https://forum.ionicframework.com/u/twestrick)\
**Post date:** [March 27, 2024, 1:47pm UTC](https://forum.ionicframework.com/t/im-just-starting-and-taking-some-hard-hits-with-sqlite-capacitor/240536/7 "2024-03-27T13:47:12Z")

</div>

Yeah, PouchDB is the one I’ve seen mentioned here. I have no experience with it though.

---

<div class="post-metadata">

**Author:** ![Amarinhu](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/amarinhu/32/146984_2.png) [@Amarinhu](https://forum.ionicframework.com/u/Amarinhu)\
**Post date:** [March 28, 2024, 11:42am UTC](https://forum.ionicframework.com/t/im-just-starting-and-taking-some-hard-hits-with-sqlite-capacitor/240536/8 "2024-03-28T11:42:34Z")

</div>

For anyone who find themselves here with the same problem, i suggest looking at this post: [Ionic React Sqlite](https://forum.ionicframework.com/t/ionic-react-sqlite/234671)

My problem is now solved. This aaronksaunders guy is a saver.

---

<div class="post-metadata">

**Author:** ![MozMike](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@MozMike](https://forum.ionicframework.com/u/MozMike)\
**Post date:** [April 2, 2024, 2:13pm UTC](https://forum.ionicframework.com/t/im-just-starting-and-taking-some-hard-hits-with-sqlite-capacitor/240536/9 "2024-04-02T14:13:07Z")

</div>

I want to print this comment, frame it, and send it to Aaron.
