**************
GN2PG Client
**************
.. image:: https://img.shields.io/badge/python-3.8+-yellowgreen
:target: https://www.python.org/
.. image:: https://img.shields.io/badge/PostgreSQL-10+-blue
:target: https://www.postgresql.org/
.. image:: https://img.shields.io/badge/packaging%20tool-poetry-important
:target: https://python-poetry.org/
.. image:: https://img.shields.io/badge/code%20style-black-black
:target: https://github.com/psf/black
.. image:: https://img.shields.io/badge/licence-AGPL--3.0-blue
:target: https://opensource.org/licenses/AGPL-3.0
.. image:: https://app.fossa.com/api/projects/git%2Bgithub.com%2Flpoaura%2FGN2PG.svg?type=shield
:target: https://app.fossa.com/projects/git%2Bgithub.com%2Flpoaura%2FGN2PG?ref=badge_shield
This project provides an import data from GeoNature_ instances to a PostgreSQL database (client side).
Widely inspired from `ClientApiVN <https://framagit.org/lpo/Client_API_VN/>`_
.. tip::
The minimum version of the source GeoNature instance required for the incremental update must be a version 2.12.0
.. contents:: Topics
.. image:: ./docs/source/_static/src_gn2pg.png
:align: center
:alt: Project logo
Project Setup
=============
GN2PG Client can be installed by running ``pip``. It requires Python 3.7.4 or above to run.
.. code-block:: bash
pip install gn2pg-client
Issues
======
Please report any bugs or requests that you have using the `GitHub issue tracker <https://github.com/lpoaura/gn2pg_client/issues>`_!
HowTo
=====
Help
####
.. code-block:: bash
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!
.. code-block:: bash
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 <https://github.com/lpoaura/GN2PG/tree/main/data/source_samples/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 <https://github.com/lpoaura/GN2PG/tree/main/data/source_samples/geonature_export_sinp_with_metadata.sql>`_
.. code-block:: TOML
# 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
InitDB Schema and tables
#########################
To create json tables where datas will be stored, run :
.. code-block:: bash
gn2pg_cli --json-tables-create <myconfigfile>
Full download
#############
To download all datas from API, run :
.. code-block:: bash
gn2pg_cli --full <myconfigfile>
Incremental download
####################
To update data since last download, run :
.. code-block:: bash
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.
.. code-block:: cron
*/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 database
####################################
Default script to auto populate GeoNature is called "to_gnsynthese".
.. code-block:: bash
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``.
Dashboard
=========
A simple web dashboard can be run following `dashboard docs <./docs/dashboard.rst>`_.
.. image:: ./docs/_static/home_gn2pg_dashboard.png
:align: center
:alt: Dashboard_Home
.. image:: ./docs/_static/src_gn2pg_dashboard.png
:align: center
:alt: Dashboard_gn2pg_downloag_log
Contributing
============
All devs must be done in forks (see `GitHub doc <https://docs.github.com/en/get-started/quickstart/fork-a-repo>`_).
Pull requests must be pulled to `dev` branch.
Install project and development requirements (require `poetry <https://python-poetry.org/>`_):
.. code-block:: bash
poetry install --with=docs --all-extras
poetry run pre-commit install
Make your devs and pull requests.
Test `gn2pg_cli` in dev mode by running this command:
.. code-block:: bash
poetry run gn2pg_cli <options>
Renew requirements file for non poetry developers
#################################################
.. code-block:: bash
poetry export -f requirements.txt > requirements.txt
Licence
=======
`GNU AGPLv3 <https://www.gnu.org/licenses/gpl.html>`_
Team
====
* `@lpofredc <https://github.com/lpofredc/>`_ (`LPO Auvergne-Rhône-Alpes <https://github.com/lpoaura/>`_), main developer
.. image:: https://raw.githubusercontent.com/lpoaura/biodivsport-widget/master/images/LPO_AuRA_l250px.png
:align: center
:height: 100px
:alt: Logo LPOAuRA
* @ophdlv (Natural Solution), contributor
* @mvergez (Natural Solution), contributor
* @andriacap (Natural Solution), contributor
* @Adrien-Pajot (Natural Solution), contributor
.. _GeoNature: https://geonature.fr
------------
With the financial support of the `DREAL Auvergne-Rhône-Alpes <http://www.auvergne-rhone-alpes.developpement-durable.gouv.fr/>`_ and the `Office français de la biodiversité <https://www.ofb.gouv.fr/>`_.
.. image:: https://data.lpo-aura.org/web/images/blocmarque_pref_region_auvergne_rhone_alpes_rvb_web.png
:align: center
:height: 100px
:alt: Logo DREAL AuRA
.. image:: https://www.ofb.gouv.fr/sites/default/files/logo-ofb.png
:align: center
:height: 100px
:alt: Logo OFB
Raw data
{
"_id": null,
"home_page": "https://github.com/lpoaura/gn2gn_client/",
"name": "gn2pg-client",
"maintainer": "lpofredc",
"docs_url": null,
"requires_python": ">=3.8.1,<4.0",
"maintainer_email": "frederic.cloitre@lpo.fr",
"keywords": "GeoNature,Export,SINP,opendata,biodiversity",
"author": "lpofredc",
"author_email": "frederic.cloitre@lpo.fr",
"download_url": "https://files.pythonhosted.org/packages/2d/71/421dbdfe9ec36164b13c6ab88d29b9c49f83f07a0549401380e7ecbe5472/gn2pg_client-1.5.1.tar.gz",
"platform": null,
"description": "**************\n GN2PG Client\n**************\n\n.. image:: https://img.shields.io/badge/python-3.8+-yellowgreen\n :target: https://www.python.org/\n.. image:: https://img.shields.io/badge/PostgreSQL-10+-blue\n :target: https://www.postgresql.org/\n.. image:: https://img.shields.io/badge/packaging%20tool-poetry-important\n :target: https://python-poetry.org/\n.. image:: https://img.shields.io/badge/code%20style-black-black\n :target: https://github.com/psf/black\n.. image:: https://img.shields.io/badge/licence-AGPL--3.0-blue\n :target: https://opensource.org/licenses/AGPL-3.0\n.. image:: https://app.fossa.com/api/projects/git%2Bgithub.com%2Flpoaura%2FGN2PG.svg?type=shield\n :target: https://app.fossa.com/projects/git%2Bgithub.com%2Flpoaura%2FGN2PG?ref=badge_shield\n\nThis project provides an import data from GeoNature_ instances to a PostgreSQL database (client side).\nWidely inspired from `ClientApiVN <https://framagit.org/lpo/Client_API_VN/>`_\n\n.. tip::\n\n The minimum version of the source GeoNature instance required for the incremental update must be a version 2.12.0\n\n.. contents:: Topics\n\n.. image:: ./docs/source/_static/src_gn2pg.png\n :align: center\n :alt: Project logo\n\n\nProject Setup\n=============\n\nGN2PG Client can be installed by running ``pip``. It requires Python 3.7.4 or above to run.\n\n.. code-block:: bash\n\n pip install gn2pg-client\n\n\nIssues\n======\n\nPlease report any bugs or requests that you have using the `GitHub issue tracker <https://github.com/lpoaura/gn2pg_client/issues>`_!\n\nHowTo\n=====\n\nHelp\n####\n\n.. code-block:: bash\n\n gn2pg_cli --help\n\nInit config file\n################\n\nThis command init a TOML config file within ``~/.gn2pg`` hidden directory (in user ``HOME`` directory), named as you want. PLEASE DO NOT SPECIFY PATH!\n\n.. code-block:: bash\n\n gn2pg_cli --init <myconfigfile>\n\n\nConfig file is structured as this. ``[[source]]`` block can be duplicate as many as needed (one block for each source).\n\nThe ``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.\nCurrent provided trigger configs are:\n\n* ``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 <https://github.com/lpoaura/GN2PG/tree/main/data/source_samples/geonature_export_sinp_with_cd_nomenclature.sql>`_\n* ``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 <https://github.com/lpoaura/GN2PG/tree/main/data/source_samples/geonature_export_sinp_with_metadata.sql>`_\n\n.. code-block:: TOML\n\n # GN2PG configuration file\n\n # Local db configuration\n [db]\n db_host = \"localhost\"\n db_port = 5432\n db_user = \"<dbUser>\"\n db_password = \"<dbPassword>\"\n db_name = \"<dbName>\"\n db_schema_import = \"schema\"\n # Additional connection options (optional)\n [db.db_querystring]\n sslmode = \"prefer\"\n\n\n # Source configuration,\n # Ducplicate this block for each source (1 source = 1 export)\n [[source]]\n # Source name, will be use to tag stored data in import table\n name = \"Source1\"\n # GeoNature source login\n user_name = \"<monuser>\"\n # GeoNature source password\n user_password = \"<monPwd>\"\n # GeoNature source URL\n url = \"<http://geonature1/>\"\n # GeoNature source Export id\n export_id = 1\n # Data type is facultative. By default the value is 'synthese'. Therefore, triggers from to_gnsynthese.sql are not activated.\n # If you want to insert your data into a GeoNature database please choose either 'synthese_with_cd_nomenclature' or 'synthese_with_metadata'.\n # If not, delete the line.\n data_type = \"synthese_with_cd_nomenclature\"\n\n\n [[source]]\n # Source configuration\n name = \"Source2\"\n user_name = \"<monuser>\"\n user_password = \"<monPwd>\"\n url = \"<http://geonature2/>\"\n export_id = 1\n data_type = \"synthese_with_cd_nomenclature\"\n\n\n\n.. tip::\n\n You can add variable in source block ``enable = false`` to disable a source\n\n\nInitDB Schema and tables\n#########################\n\nTo create json tables where datas will be stored, run :\n\n.. code-block:: bash\n\n gn2pg_cli --json-tables-create <myconfigfile>\n\n\nFull download\n#############\n\nTo download all datas from API, run :\n\n.. code-block:: bash\n\n gn2pg_cli --full <myconfigfile>\n\nIncremental download\n####################\n\nTo update data since last download, run :\n\n.. code-block:: bash\n\n gn2pg_cli --update <myconfigfile>\n\n\nTo automate the launching of updates, you can write the cron task using the following command, for example every 30 minutes.\n\n.. code-block:: cron\n\n */30 * * * * /usr/bin/env bash -c \"source <path to python environment>/bin/activate && gn2pg_cli --update <myconfigfile>\" > /dev/null 2>&1\n\n\nDebug mode\n##########\n\nDebug mode can be activated using ``--verbose`` CLI argument\n\nLogs\n####\n\nLog files are stored in ``$HOME/.gn2pg/log`` directory.\n\nImport datas into GeoNature database\n####################################\n\nDefault script to auto populate GeoNature is called \"to_gnsynthese\".\n\n.. code-block:: bash\n\n gn2pg_cli --custom-script to_gnsynthese <myconfigfile>\n\n\n.. tip::\n\n You can also replacing synthese script by your own scripts, using file path instead of ``to_gnsynthese``.\n\n\nDashboard\n=========\n\nA simple web dashboard can be run following `dashboard docs <./docs/dashboard.rst>`_.\n\n.. image:: ./docs/_static/home_gn2pg_dashboard.png\n :align: center\n :alt: Dashboard_Home\n\n\n\n.. image:: ./docs/_static/src_gn2pg_dashboard.png\n :align: center\n :alt: Dashboard_gn2pg_downloag_log\n\nContributing\n============\n\nAll devs must be done in forks (see `GitHub doc <https://docs.github.com/en/get-started/quickstart/fork-a-repo>`_).\n\nPull requests must be pulled to `dev` branch.\n\nInstall project and development requirements (require `poetry <https://python-poetry.org/>`_):\n\n.. code-block:: bash\n\n poetry install --with=docs --all-extras\n poetry run pre-commit install\n\nMake your devs and pull requests.\n\nTest `gn2pg_cli` in dev mode by running this command:\n\n.. code-block:: bash\n\n poetry run gn2pg_cli <options>\n\nRenew requirements file for non poetry developers\n#################################################\n\n.. code-block:: bash\n\n poetry export -f requirements.txt > requirements.txt\n\n\nLicence\n=======\n\n`GNU AGPLv3 <https://www.gnu.org/licenses/gpl.html>`_\n\nTeam\n====\n\n* `@lpofredc <https://github.com/lpofredc/>`_ (`LPO Auvergne-Rh\u00f4ne-Alpes <https://github.com/lpoaura/>`_), main developer\n\n.. image:: https://raw.githubusercontent.com/lpoaura/biodivsport-widget/master/images/LPO_AuRA_l250px.png\n :align: center\n :height: 100px\n :alt: Logo LPOAuRA\n\n* @ophdlv (Natural Solution), contributor\n* @mvergez (Natural Solution), contributor\n* @andriacap (Natural Solution), contributor\n* @Adrien-Pajot (Natural Solution), contributor\n\n.. _GeoNature: https://geonature.fr\n\n------------\n\nWith the financial support of the `DREAL Auvergne-Rh\u00f4ne-Alpes <http://www.auvergne-rhone-alpes.developpement-durable.gouv.fr/>`_ and the `Office fran\u00e7ais de la biodiversit\u00e9 <https://www.ofb.gouv.fr/>`_.\n\n.. image:: https://data.lpo-aura.org/web/images/blocmarque_pref_region_auvergne_rhone_alpes_rvb_web.png\n :align: center\n :height: 100px\n :alt: Logo DREAL AuRA\n\n.. image:: https://www.ofb.gouv.fr/sites/default/files/logo-ofb.png\n :align: center\n :height: 100px\n :alt: Logo OFB\n",
"bugtrack_url": null,
"license": "AGPL-3.0-or-later",
"summary": "Import tool from GeoNature to a PostgreSQL database through Export module API (client side)",
"version": "1.5.1",
"project_urls": {
"Homepage": "https://github.com/lpoaura/gn2gn_client/"
},
"split_keywords": [
"geonature",
"export",
"sinp",
"opendata",
"biodiversity"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "9653e5d9e2f60de99a06e713ac4ef39f2122ad6ac96c8f987066839368a57e18",
"md5": "f201f9fd1670ba82b8c617adc0db33c2",
"sha256": "08dc5343df65fe0feceede631d27c3aa33fa7a2bd803d835eb481905eed45cd7"
},
"downloads": -1,
"filename": "gn2pg_client-1.5.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f201f9fd1670ba82b8c617adc0db33c2",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8.1,<4.0",
"size": 85689,
"upload_time": "2023-05-29T15:18:06",
"upload_time_iso_8601": "2023-05-29T15:18:06.733055Z",
"url": "https://files.pythonhosted.org/packages/96/53/e5d9e2f60de99a06e713ac4ef39f2122ad6ac96c8f987066839368a57e18/gn2pg_client-1.5.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2d71421dbdfe9ec36164b13c6ab88d29b9c49f83f07a0549401380e7ecbe5472",
"md5": "21257161237dee1a6fa5bf18d06797d3",
"sha256": "7bff08abb6bd18049c13ab4c7194dcd2e4728f2b4be75bc415ba3e509fe4a457"
},
"downloads": -1,
"filename": "gn2pg_client-1.5.1.tar.gz",
"has_sig": false,
"md5_digest": "21257161237dee1a6fa5bf18d06797d3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8.1,<4.0",
"size": 80269,
"upload_time": "2023-05-29T15:18:08",
"upload_time_iso_8601": "2023-05-29T15:18:08.496205Z",
"url": "https://files.pythonhosted.org/packages/2d/71/421dbdfe9ec36164b13c6ab88d29b9c49f83f07a0549401380e7ecbe5472/gn2pg_client-1.5.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-29 15:18:08",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "lpoaura",
"github_project": "gn2gn_client",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"tox": true,
"lcname": "gn2pg-client"
}