I am developing a Django application that will use multiple database backends. I would like to host the sqlite database on the machine running the django application and synchronize with the remote mysql database. The hard part is that the machine on which the application is running will not always have an Internet connection, so the mysql database is not always available. There will be several computers running the application, each of which has its own local sqlite database, but all use the same remote mysql database.
I haven't written the code yet, but here is what I mean. Each time I run an insert or update, I would like to write it to both databases if the remote database is not available, in which case I will save the sql statement in a table in the local database to run when the remote database is available.
Can this be done using database routers, or do I need to manually implement this with each db instruction?
Note on PC: It is not directly related, but it will certainly be offered. A primary key will be generated locally on each machine. In mysql DB there will be a field for this key and a field with a unique identifier for each application instance, which together will provide a unique key.
source share