Skip to main content

Powerful tool for truly synchronizing data and its relationships in database tables. Truly maps Foreign Keys and their on_delete rules in Django.

Project description

DjangoSyncMaster

Description

Powerful tool for truly synchronizing data and its relationships in database tables.

  • Truly maps Foreign Keys and their on_delete rules in Django.

Django uses a migration system based on ORM (Object-Relational Mapping) to make changes to the database, However, this can become problematic when using Foreign Keys, since Django does not implement ON DELETE when synchronizing the database... This can be problematic if you want to change the data directly in the database.

This library aims to bring this automation to Django. When you perform a migration, the script will automatically read the tables created in models.py (ignoring any table that has not been declared outside of your app's models.py, this includes third-party tables and Django's own standards).

As soon as it performs a reading and separates the tables that were actually declared manually in models.py, it will create a map of your Foreign Keys and recreate them manually, one by one. With the configuration defined in your models.py.

This library aims to bring speed and automation to the development environment. (Not recommended for implementation environments)

This way, you won't need to edit a migration directly or modify the database by hand.

obs: I am not responsible for any type of data loss, as previously stated, this library aims to streamline the development environment and not to manage the implemented project.

How to use

  1. Install the package using pip:
pip install DjangoSyncMaster
  1. Add 'DjangoSyncMaster' to your Django app's apps.py file:
from django.apps import AppConfig
from django.conf import settings

from DjangoSyncMaster import sync_db

class AppNameConfig(AppConfig):
	name = 'app_Name'

	def ready(self):
		from django.db.models.signals import post_migrate # await migrate

	def handler(sender, **kwargs): # for pull Django instance info
		sync_db(sender,db_settings=settings.DATABASES)

  post_migrate.connect(handler, sender=self) #Execute function pos-migrate
  1. Make migrations
python manage.py makemigrations
python manage.py migrate

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

djangosyncmaster-1.0.1.tar.gz (18.7 kB view details)

Uploaded Source

Built Distribution

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

djangosyncmaster-1.0.1-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

Details for the file djangosyncmaster-1.0.1.tar.gz.

File metadata

  • Download URL: djangosyncmaster-1.0.1.tar.gz
  • Upload date:
  • Size: 18.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for djangosyncmaster-1.0.1.tar.gz
Algorithm Hash digest
SHA256 f084cbdb8a846d3c3fe034bbb25776a6c79577c33ba3570cf75ead454969be98
MD5 843049fd304986f65a61997de3f67a0a
BLAKE2b-256 6e98264acbc0a153282f57bd107025e3af40403ec09718793268c0dd7ab805cc

See more details on using hashes here.

File details

Details for the file djangosyncmaster-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for djangosyncmaster-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e6e337429e2f536f253bf3029eda76203ad6c9b679f94af2161ab5386e9fe9c4
MD5 08d80d2868f42e9524dd6e6bf6d1cf75
BLAKE2b-256 80a0ed91f410c4db0a02909fb57c36bb6317444ec5d8348b016df483574ffa22

See more details on using hashes here.

Supported by

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