Giter Site home page Giter Site logo

pierre56 / gn2pg Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lpoaura/gn2pg

0.0 0.0 0.0 3.12 MB

Outil d'import de données entre instances GeoNature (côté client)

Home Page: https://gn2pg.readthedocs.io/

License: GNU Affero General Public License v3.0

Python 45.63% Makefile 0.80% PLpgSQL 53.04% Dockerfile 0.53%

gn2pg's Introduction

GN2PG Client

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 data from GeoNature instances to a PostgreSQL database (client side). Widely inspired from ClientApiVN

Project logo

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

pip install gn2pg-client

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

gn2pg_cli --help

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).

The data_type value on each source is used to characterize the type of data. This value is used to identify which triggers to be triggered when inserting, updating or deleting data. Current provided trigger configs are:

  • synthese_with_cd_nomenclature which provide triggers to insert basically data on synthese and generate basic metadatas (acquisition framework and datasets). Source query sample is provided in file geonature_export_sinp_with_cd_nomenclature.sql
  • synthese_with_metadata which provide triggers to insert data in synthese and populate most of the metadata data (acquisition frameworks, datasets, actors such as organisms and roles, territories, etc.). Source query sample is provided in file geonature_export_sinp_with_metadata.sql
# 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 data into a GeoNature database please choose either 'synthese_with_cd_nomenclature' or 'synthese_with_metadata'.
# 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"

Tip

You can add variable in source block enable = false to disable a source

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

gn2pg_cli --json-tables-create <myconfigfile>

To download all datas from API, run :

gn2pg_cli --full <myconfigfile>

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 can be activated using --verbose CLI argument

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

Default script to auto populate GeoNature is called "to_gnsynthese".

gn2pg_cli --custom-script to_gnsynthese <myconfigfile>

Tip

You can also replacing synthese script by your own scripts, using file path instead of to_gnsynthese.

All devs must be done in forks (see GitHub doc).

Pull requests must be pulled to dev branch.

Install project and development requirements (require poetry):

poetry install

Make your devs and pull requests.

Test gn2pg_cli in dev mode by running this command:

poetry run gn2pg_cli <options>
poetry export -f requirements.txt > requirements.txt

GNU AGPLv3

Logo LPOAuRA

  • @ophdlv (Natural Solution), contributor
  • @mvergez (Natural Solution), contributor
  • @andriacap (Natural Solution), contributor
  • @Adrien-Pajot (Natural Solution), contributor

With the financial support of the DREAL Auvergne-Rhône-Alpes and the Office français de la biodiversité.

Logo DREAL AuRA

Logo OFB

gn2pg's People

Contributors

lpofredc avatar hypsug0 avatar ophdlv avatar adrien-pajot avatar camillemonchicourt avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.