Skip to main content

No project description provided

Project description

django-sync-model

a django reusable application to migrate data from source table to target table.

Install

pip3 install django-sync-model

add sync_model to INSTALLED_APPS in settings.py

Usage

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.

  1. 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
  1. run sync task
python3 manage.py sync_model

Features

  • 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

Release Notes

  • 0.5.0 break change: sync_function should return SyncResult

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_sync_model-0.7.0.tar.gz (9.5 kB view hashes)

Uploaded Source

Built Distribution

django_sync_model-0.7.0-py3-none-any.whl (13.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page