djangopandasopenpyxlxlrddjango-import-export

django "import excel to database" libraries


I need to do "import excel to database" using django.

I know that some of the libraries that help are "django-import-export", "openpyxl", and others are "pandas", "xlrd", etc.

What is the difference between these libraries? Which library is right for what I'm trying to do?


Solution

  • django-import-export adds features on top of the other libraries, such as validation, batch support, error checking, handling creates vs updates, permissions etc.

    django-import-export also offers Admin UI integration as a key feature, so you can browse to your xlsx file, preview and import etc. There are lots of other features, so if import via Admin UI is required, it is worth looking into it further (v4 is in beta).

    django-import-export also offers a programmatic mode, so you can import via scripts etc.

    django-import-export uses xlrd, openpyxl and pandas internally as part of the tablib library.

    The other libraries will allow you to read and parse xls(x) content, but you will have to write most of the import code yourself.

    I would consider whether the import will be a one-off, or whether it needs to be a part of your application. If the latter, take a look at django-import-export.