Integrate INSEE Sirene v3 database in Django project
Project description
django-insee-sirene
Allow to download and import the INSEE Sirène csv files in django models.
Requirements
- Python 3.12+
- Django 4.2+
Installation
- your
DB_ENGINE
setting must be"django.contrib.gis.db.backends.postgis"
- run
pip install django-insee-sirene
- add
insee_sirene
to yourINSTALLED_APPS
- run
python manage.py migrate insee_sirene
Download source files
You can use the download management command to download the csv source files :
python manage.py download_insee_sirene_csv_files
The files are downloaded and extracted in a insee_sirene/management/commands/data
folder.
They can then be used by the import_insee_sirene
and generate_insee_sirene_models
commands.
Caution: Keep in mind that files are not removed after calling this command.
By default, the command doesn't re-download the files if they are already in the folder.
Command options:
- Force :
-f
or--force-download
: Force the download of the files - Only :
-o
or--only
: Download only the given file (ex: -o StockEtablissement_utf8.zip) - Keep archives :
-k
or--keep-archives
: Keep the .zip archives after extraction
Import
Launch the import management command to download the source import files and download the data in the database :
python manage.py import_insee_sirene
Command options:
- Force :
-f
or--force-download
: Force the download of the files - Keep sources folder :
-k
or--keep-sources-folder
: Keep downloaded sources folder after import - Chunk size :
--chunk
: Amount of lines to read at once and objects bulk created (1000 by default)
Update models
The models are generated by the generate_insee_sirene_models
management command.
This command is used to easily generate the models from the csv import files and must be used only by the repository maintainer or if you wish to submit a merge request, following the CONTRIBUTING.md guide.
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
Built Distribution
Hashes for django_insee_sirene-0.0.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2093335e2ca99a9754426dd76af03cf64f04cfa95b7833d5245bdb3dd9aab75 |
|
MD5 | bd6f4af9117de44c27d0480080920b92 |
|
BLAKE2b-256 | 75f431f75b7312a611ef151a2650d325519293f690dfc6de3ab4731ac00477ad |
Hashes for django_insee_sirene-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e57bf9a557461d8ea1da3ce84b0f7b190a958413f5cc3d64edc06bbf37b664e |
|
MD5 | e5230ceb5b4a9496b29307483d1659aa |
|
BLAKE2b-256 | c65a45841aca8db2e3607fbf4f7b8779ff9d73e5fcb630aebc81177f9aca5352 |