a django reusable application to migrate data from source table to target table.
pip3 install django-sync-model
add sync_model
to INSTALLED_APPS
in settings.py
for example you may has connected to a stock database provided by the broker.
you want to save some filtered data to your own database to create foreignkey.
- create a sync task
from sync_model.models import (
RawStockAction, StockAction,
SyncTask,
)
SyncTask.objects.create(
source=ContentType.objects.get_for_model(RawStockAction),
target=ContentType.objects.get_for_model(StockAction),
sync_method="sync_model.utils.sync_raw_stock_action",
batch_size=2,
order_by=["update_datetime", "-sender"],
filter_by={
"canceled": False,
}
)
here your sync_method should return a sync result
- run sync task
python3 manage.py sync_model
- support sync data from one database to another
- incremental update
- support non-cycle dependency
- support filter
- support custom sync size of each table
- support foreign key sort
- support exclude filters
- support timeout parameter
- support None value
- 0.5.0
break change:
sync_function
should returnSyncResult