Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

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

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.

Files for django-excel-fixture, version 0.1
Filename, size File type Python version Upload date Hashes
Filename, size django_excel_fixture-0.1-py3-none-any.whl (8.2 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size django-excel-fixture-0.1.tar.gz (6.6 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page