1đź‘Ť
There’s really no “best method for data syncing” in Django.
Really, this is all about how you design your data models.
A few tips:
- Figure out your source systems unique identifier for each object. Usually this is just something like “id” or whatever.
-
Always, always, store a created and modified date on your models. This will make sync easier. I usually do it like so:
created_on = models.DateTimeField('Created On', auto_now_add=True) last_modified = models.DateTimeField('Last Modified', auto_now=True)
-
With those two bits in place (and all the other fields you need to store), it’s just a matter or writing code which will retrieve all the records from the source system and check them against the records you have. This will be a tedious process, and completely manual. There is no “django-magic-model-sync” thing for this type of project. Just the hard work of fetching the records from the source, checking them against your data store, and updating what needs to be updated.
- You’ll probably want to use Celery, since I imagine you’ll want to do this sync every X minutes, or hours, or days, or whatever. So you’ll want to write a Celery task which does #3.
0đź‘Ť
u can use Django with multiple databases .
DATABASES = {
'default': {
'NAME': 'app_data',
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'USER': 'postgres_user',
'PASSWORD': 's3krit'
},
'items': {
'NAME': 'items_data',
'ENGINE': 'django.db.backends.mysql',# or what ever Engine
'USER': 'mysql_user',
'PASSWORD': 'priv4te'
}
}
and you can sync the dedicated db only .
./manage.py syncdb --database=items
in your models you can use like Eg:
Items.objects.using('items').all()
- [Answer]-Django heavy database query and data processing
- [Answer]-OpenERP DB Connectivity with Django
- [Answer]-Django retrieving users from tuples
- [Answer]-Digital Ocean Django app is only working with Debug=True