Package: gn2pg_client
This project provides an import data fromGeoNatureinstances to a PostgreSQL database (client side).
Widely inspired fromClientApiVNTipThe minimum version of the source GeoNature instance required for the incremental update must be a version 2.12.0TopicsProject SetupIssuesHowToHelpInit config fileInitDB  Schema and tablesFull downloadIncremental downloadDebug modeLogsImport datas into GeoNature databaseDashboardContributingRenew requirements file for non poetry developersLicenceTeamProject SetupGN2PG Client can be installed by runningpip. It requires Python 3.7.4 or above to run.pipinstallgn2pg-clientIssuesPlease report any bugs or requests that you have using theGitHub issue tracker!HowToHelpgn2pg_cli--helpInit config fileThis command init a TOML config file within~/.gn2pghidden directory (in userHOMEdirectory), 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).Thedata_typevalue 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_nomenclaturewhich provide triggers to insert basically data on synthese and generate basic metadatas (acquisition framework and datasets). Source query sample is provided in filegeonature_export_sinp_with_cd_nomenclature.sqlsynthese_with_metadatawhich 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 filegeonature_export_sinp_with_metadata.sql# GN2PG configuration file# Local db configuration[db]db_host="localhost"db_port=5432db_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 tablename="Source1"# GeoNature source loginuser_name="<monuser>"# GeoNature source passworduser_password="<monPwd>"# GeoNature source URLurl="<http://geonature1/>"# GeoNature source Export idexport_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 configurationname="Source2"user_name="<monuser>"user_password="<monPwd>"url="<http://geonature2/>"export_id=1data_type="synthese_with_cd_nomenclature"TipYou can add variable in source blockenable = falseto disable a sourceInitDB  Schema and tablesTo create json tables where datas will be stored, run :gn2pg_cli--json-tables-create<myconfigfile>Full downloadTo download all datas from API, run :gn2pg_cli--full<myconfigfile>Incremental downloadTo 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>&1Debug modeDebug mode can be activated using--verboseCLI argumentLogsLog files are stored in$HOME/.gn2pg/logdirectory.Import datas into GeoNature databaseDefault script to auto populate GeoNature is called “to_gnsynthese”.gn2pg_cli--custom-scriptto_gnsynthese<myconfigfile>TipYou can also replacing synthese script by your own scripts, using file path instead ofto_gnsynthese.DashboardA simple web dashboard can be run followingdashboard docs.ContributingAll devs must be done in forks (seeGitHub doc).Pull requests must be pulled todevbranch.Install project and development requirements (requirepoetry):poetryinstall--with=docs--all-extraspoetryrunpre-commitinstallMake your devs and pull requests.Testgn2pg_cliin dev mode by running this command:poetryrungn2pg_cli<options>Renew requirements file for non poetry developerspoetryexport-frequirements.txt>requirements.txtLicenceGNU AGPLv3Team@lpofredc(LPO Auvergne-Rhône-Alpes), main developer@ophdlv (Natural Solution), contributor@mvergez (Natural Solution), contributor@andriacap (Natural Solution), contributor@Adrien-Pajot (Natural Solution), contributorWith the financial support of theDREAL Auvergne-Rhône-Alpesand theOffice français de la biodiversité.