Skip to main content

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

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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

Details for the file django_sync_model-0.7.0.tar.gz.

File metadata

  • Download URL: django_sync_model-0.7.0.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for django_sync_model-0.7.0.tar.gz
Algorithm Hash digest
SHA256 2c5f37035cc41262505f41f19b5aebdbfd790041568db746166d87181b359ba2
MD5 670f7429f77e0937c96f81864e809c78
BLAKE2b-256 e52e0ea4cbeb695350a824bdf9f60bddc89abf2045f560a48c00234edd304a39

See more details on using hashes here.

File details

Details for the file django_sync_model-0.7.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_sync_model-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 77a3911471dbfcf142302094be23b83861fa9c7f6397e1988b7b6982f4219827
MD5 d22479f9f5f3ae50fd7fd7ce66ce4020
BLAKE2b-256 69bff7b51571c38b3b59728b1f51457980bab94db459e5e61191084cd6a14255

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.7.0 This release

2 files

0.5.2

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page