Skip to main content

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 your INSTALLED_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

django_insee_sirene-0.0.5.tar.gz (29.7 kB view details)

Uploaded Source

Built Distribution

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

django_insee_sirene-0.0.5-py3-none-any.whl (35.3 kB view details)

Uploaded Python 3

File details

Details for the file django_insee_sirene-0.0.5.tar.gz.

File metadata

  • Download URL: django_insee_sirene-0.0.5.tar.gz
  • Upload date:
  • Size: 29.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for django_insee_sirene-0.0.5.tar.gz
Algorithm Hash digest
SHA256 3e762c97ac1c63564743a29ceb847766e454a47a0635314b3f743ba80c66e203
MD5 ebab2e63d30ad611b559f0285cc04d55
BLAKE2b-256 c63f7876bc878b857090e7d68b5d6df3178ed1048eefd23cda6ddfcf1295fe2a

See more details on using hashes here.

File details

Details for the file django_insee_sirene-0.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for django_insee_sirene-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 c0225b17dee75060ad37b6e30173d7c2a4f964b2c57599eeb437c46b3d6f97c4
MD5 67250d4c449f64cdb109fcdc3bb823af
BLAKE2b-256 51ff7872412adea0b2ee479f9d49a8e15f28e4e929f1123f21b5d877de1381a0

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