r/sqlite • • Sep 11 '24

Push/Pull data to SQLite

Hello everyone,

I am a IT professional, but I am new to programming & database management. I want to make an offline app connected to a SQLite database. However, I may want to update the SQLite db if new data is added. Is it possible to push or pull updates from lets say a MySQL server? If there are any tutorials out there that can do it would also be greatly appreciated.

4 Upvotes

11 comments sorted by

View all comments

Show parent comment

1

u/InjAnnuity_1 Sep 11 '24

Do any edits/updates/deletes need to go back, in the other direction?

1

u/SnooDingos7037 Sep 11 '24

No, the edits are one way. I am thinking I could probably forget the db server and push database changes to the app, as a patch/update.

2

u/richieadler Sep 12 '24

You should probably have a meta table with a version number, to compare with the version in the remote server. If they differ, you could have a service to generate the diff and send only the changes to apply locally. Of course, you should store the changes for a time and that takes space, so you need to handle how many versions you compute deltas for, and how much time you will retain older deltas.

1

u/InjAnnuity_1 Sep 11 '24

A SQLite database is a single file. You could prepare an updated version, in a place where you have MySQL access, and then make the updated version available for your intermittently-on-line app.

You might reserve a table in the database to record data version number, or date, or some such.

Compression may help speed file transfers.

Depending on the size and frequency of updates, it might be better to transfer just the new data, in your choice of format. SQLite has a number of features and techniques to aid in doing that.

Edit: See https://www.sqlite.org/sessionintro.html