Library to add a view (server) and management command (client) to copy model data
Project description
django-copy-tables
This utility allows for copying tables from a production/staging server to a development copy. This allows developing against full datasets.
Installation
It's on pypi, so install via pip (or add to your requirements.txt)
pip3 install django-copy-tables
in your settings.py
- add to your INSTALLED_APPS "django_copy_tables"
- add a line:
TABLE_COPY_PASSWORD="a password"
at the end of your urls.py add:
from django_copy_tables import get_table
urlpatterns.append(path('copyTables', get_table))
Usage
Once your source distribution has been updated and the view/password is live, then on your local install you can use the standard manage.py with the command copyTables
The general syntax is:
./manage.py copyTables <module name> <table name> <src url> <copy pass> [--clear] [--step X] [--ignore colname]
For example if you have a table named Author in module named Blog at http://my.blog with copy password zz11 you can copy that table to your local machine with:
./manage.py copyTables Blog Author http://my.blog zz11
By default it does not delete records locally, but will overwrite local records with the same primary key as the remote. To delete the local records before syncing use --clear.
By default it will copy 100 records at a time. If your records are large you may want to set --step to something lower.
If you are syncing a table with complex data structures (looping generally) sometimes you need to ignore a foreign key column to get the initial record loaded, load some other data, then load it again without ignoring. that is what the --ignore flag is for. it will ignore the column completly (the model will be set to the default generally.) Run it again without the clear or ignore flags after the other data is in place.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django_copy_tables-0.1.9.tar.gz
.
File metadata
- Download URL: django_copy_tables-0.1.9.tar.gz
- Upload date:
- Size: 16.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.22.0 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6878b1afe2a4c03aab73612136e05279a5d1b2bca926bf9446a47efcc1b7687d |
|
MD5 | cef13ef00715dbf9d316abc38656ec1a |
|
BLAKE2b-256 | a3fa347f03c45ee643b94f4d2167af73f2e12c9a2db9eaee1994e9cbbbb4dc1d |
File details
Details for the file django_copy_tables-0.1.9-py3-none-any.whl
.
File metadata
- Download URL: django_copy_tables-0.1.9-py3-none-any.whl
- Upload date:
- Size: 17.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.22.0 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc66307ecd3b7025f8b5dc9aa39b09c1c1732f90ba187a9ff77792bcfe107e33 |
|
MD5 | a65f35eb325796f8ca2232d21a1acdc3 |
|
BLAKE2b-256 | 9101591c5388be59af34a539ac877b6634f648f111ea375ba2e94bc4511eea07 |