Skip to main content

Import tool from GeoNature to a PostgreSQL database through Export module API (client side)

Project description

https://img.shields.io/badge/python-3.7+-yellowgreen https://img.shields.io/badge/PostgreSQL-10+-blue https://img.shields.io/badge/packaging%20tool-poetry-important https://img.shields.io/badge/code%20style-black-black https://img.shields.io/badge/licence-AGPL--3.0-blue https://app.fossa.com/api/projects/git%2Bgithub.com%2Flpoaura%2FGN2PG.svg?type=shield

This project provides an import tool between GeoNature instances (client side). Widely inspired from ClientApiVN

Project logo

Project Setup

GN2PG Client can be installed by running pip. It requires Python 3.7.4# to run.

pip install gn2pg-client

Issues

Please report any bugs or requests that you have using the GitHub issue tracker!

HowTo

Help

gn2pg_cli --help

Init config file

This command init a TOML config file within ~/.gn2pg hidden directory (in user HOME directory), named as you want. PLEASE DO NOT SPECIFY PATH!

gn2pg_cli --init <myconfigfile>

Config file is structured as this. [[source]] block can be duplicate as many as needed (one block for each source).

# GN2PG configuration file

# Local db configuration
[db]
db_host = "localhost"
db_port = 5432
db_user = "<dbUser>"
db_password = "<dbPassword>"
db_name = "<dbName>"
db_schema_import = "schema"
    # Additional connection options (optional)
    [db.db_querystring]
    sslmode = "prefer"


# Source configuration,
# Ducplicate this block for each source (1 source = 1 export)
[[source]]
# Source name, will be use to tag stored data in import table
name = "Source1"
# GeoNature source login
user_name = "<monuser>"
# GeoNature source password
user_password = "<monPwd>"
# GeoNature source URL
url = "<http://geonature1/>"
# GeoNature source Export id
export_id = 1
# Data type is facultative. By default the value is 'synthese'. Therefore, triggers from to_gnsynthese.sql are not activated.
# If you want to insert your date into a GeoNature database please choose either 'synthese_with_cd_nomenclature' or 'synthese_with_label'.
# If not, delete the line.
data_type = "synthese_with_cd_nomenclature"


[[source]]
# Source configuration
name = "Source2"
user_name = "<monuser>"
user_password = "<monPwd>"
url = "<http://geonature2/>"
export_id = 1
data_type = "synthese_with_cd_nomenclature"

InitDB Schema and tables

To create json tables where datas will be downloaded, run :

gn2pg_cli --json-tables-create <myconfigfile>

Full download

To download all datas from API, run :

gn2pg_cli --full <myconfigfile>

Incremental download

To update data since last download, run :

gn2pg_cli --update <myconfigfile>

To automate the launching of updates, you can write the cron task using the following command, for example every 30 minutes.

*/30 * * * * /usr/bin/env bash -c "source <path to python environment>/bin/activate && gn2pg_cli --update <myconfigfile>" > /dev/null 2>&1

Debug mode

Debug mode can be activated using --verbose CLI argument

Logs

Log files are stored in $HOME/.gn2pg/log directory.

Import datas into GeoNature datas

Default script to auto populate GeoNature is called “to_gnsynthese”.

gn2pg_cli --custom-script to_gnsynthese <myconfigfile>

Contributing

All devs must be done in forks.

Pull requests must be pulled to dev branch. For example with this command:

gh repo fork --clone lpoaura/gn2pg_client

Install project and development requirements (require poetry):

poetry install

Make your devs and pull requests.

Run gn2pg_cli command in dev mode

poetry run gn2pg_cli <options>

Renew requirements file for non poetry developers

poetry export -f requirements.txt > requirements.txt

Licence

GNU AGPLv3

Team

Logo LPOAuRA

With the financial support of the DREAL Auvergne-Rhône-Alpes.

Logo DREAL AuRA

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

gn2pg_client-0.1.1.dev0.tar.gz (39.3 kB view details)

Uploaded Source

Built Distribution

gn2pg_client-0.1.1.dev0-py3-none-any.whl (40.2 kB view details)

Uploaded Python 3

File details

Details for the file gn2pg_client-0.1.1.dev0.tar.gz.

File metadata

  • Download URL: gn2pg_client-0.1.1.dev0.tar.gz
  • Upload date:
  • Size: 39.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.7.4 Linux/5.11.0-38-generic

File hashes

Hashes for gn2pg_client-0.1.1.dev0.tar.gz
Algorithm Hash digest
SHA256 6a6c966f1d4b7db23117c8e94bb1940ea4841639ebcce385592e166f554ac190
MD5 3ee586f3e8de8616023c02a0daf7e443
BLAKE2b-256 2a8cc6ef85a9aae31dfae0746931f7d2f0ab551fefbb3a3d3c7bf8a9a16c712e

See more details on using hashes here.

File details

Details for the file gn2pg_client-0.1.1.dev0-py3-none-any.whl.

File metadata

  • Download URL: gn2pg_client-0.1.1.dev0-py3-none-any.whl
  • Upload date:
  • Size: 40.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.7.4 Linux/5.11.0-38-generic

File hashes

Hashes for gn2pg_client-0.1.1.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 80fc38931d294679de48727fbdd4b24a1b9c830b9b240e99137bedf5f3505eeb
MD5 45635ccd8bff260d5a821f6514137a0a
BLAKE2b-256 58a215b0ae71eb9086d9e9a7aeb3bef4a1067aa0a82fae8d722d593bd7523fa4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page