Home  >  Q&A  >  body text

How to publish SQLite database data to an online MySQL database in Flutter?

How to synchronize offline SQLite to MySQL online database in Flutter? Any suggestions?

P粉590428357P粉590428357344 days ago788

reply all(2)I'll reply

  • P粉295728625

    P粉2957286252023-11-11 00:53:30

    Do you want to keep data synchronized between your device and server offline or online?

    Use package: https://pub.dev/packages/objectbox

    For more information, please visit: https://objectbox.io/sync

    reply
    0
  • P粉818561682

    P粉8185616822023-11-11 00:21:13

    Sounds like you're looking for offline-first architecture. In short, in this architecture, your application only communicates with the local database. Your local database (SQLite) will communicate with the server database (MySQL).

    To synchronize two databases you have to send updates or new data from your local database (via API) to the server where you will handle the data merging and then get back the merged data for saving if there are any updates on the server database or new data, it will be returned to the local database.

    The most important issue you will face when synchronizing your database is data conflicts from multiple client applications. For example, two people update the same data at the same time. So you have to make some decisions on the server side, like whose data should have higher priority.

    In the local database, you must maintain the synchronization status of each table, such as the last synchronized data time and the last updated date time. On the server database you need the last updated date time for each table. Then with the help of these dates, you can determine if there is any new or updated data that needs to be synchronized.

    reply
    0
  • Cancelreply