Skip to main content

Django: import data, export data and test using xlsx files.

Project description

Django Excel Fixture

Build Status

Django-excel-fixture is an easy way to import, export and test using .xlsx file.

Motivation

Excel is a must in the corporate world. It is an easy to use and highly powerful application, currently being used by millions of users (maybe more than a billion user). Django-excel-fixture provides a way to import, export data using excel file (.xlsx); and also use it as test fixture.

Installation

To install it, simply:

$ pip install django-excel-fixture

Then add it to your INSTALLED_APPS on your settings.py:

INSTALLED_APPS = (
    #...
    'django_excel_fixture',
)

Usage

Exporting data from database:

If you already have some data in the database, to export it to a .xlsx file:

$ python manage.py dumpdata --format xlsx --output myfilename.xlsx

It is also possible to select a specific model:

$ python manage.py dumpdata myapp1.MyModelName --format xlsx --output myfilename.xlsx
  • If you leave out the output option, the table is dumped to stdout in CSV format.
  • There will be sheets only for table with data

Importing data into the database:

To manually load the data from the Excel file, use:

$ python manage.py loaddata myfilename.xlsx

Using as test fixture:

To use the fixture in a test, just add to the test class:

class MyTestCase(TestCase):
    fixtures = ['myfilename.xlsx']

    def ...
  • No performance optimization has been made. Caution is advised.

Excel file format

  • Currently, it is only compatible with .xlxs format.
  • Every sheet is a model. The sheet title represents the model's identification.
  • Every column represents a field.
  • Every row represents a object (database entry).

Contribution

git clone git@github.com:SKisContent/django-excel-fixture.git
cd django-excel-fixture
python -m venv .venv
source .venv/scripts/activate
pip install -r requirements.txt
python runtests.py

Authors

License

The MIT License.

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

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

Source Distribution

django-excel-fixture-0.1.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

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

django_excel_fixture-0.1-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file django-excel-fixture-0.1.tar.gz.

File metadata

  • Download URL: django-excel-fixture-0.1.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

File hashes

Hashes for django-excel-fixture-0.1.tar.gz
Algorithm Hash digest
SHA256 1d47c2146b8e7ee7830a512dd807fc01cb0ec3f099d1a9a97f1869df2db1e95a
MD5 4cb840454ecac15f5890e8ca0ef0aaf7
BLAKE2b-256 2f64cbd080e3f5c58461d942d556fbcfa87188355ae12f8af1882e4f36cdc5f5

See more details on using hashes here.

File details

Details for the file django_excel_fixture-0.1-py3-none-any.whl.

File metadata

  • Download URL: django_excel_fixture-0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

File hashes

Hashes for django_excel_fixture-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3b68232ee3380241c7c07e148bc24f20d1cc02cfa321ecbcba935aa4e5000e0d
MD5 5d2612ab7cf96fa8c5ca49e0af2611a9
BLAKE2b-256 825a55f8821adabe65ecb2343ce95e115fa62ead3931183651b1f9c0bad37319

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