sauv 2021

This commit is contained in:
MaelREBOUX 2021-10-24 16:06:14 +02:00
parent d5c24653d1
commit 45032dd55b
2 changed files with 82 additions and 0 deletions

BIN
qgis/ar-redadeg2021.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 KiB

View file

@ -0,0 +1,82 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import configparser
import argparse
from argparse import RawTextHelpFormatter
import psycopg2
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
def initVariables():
# lecture du fichier de configuration qui contient les infos de connection aux bases de données
config = configparser.ConfigParser()
config.read('config.ini')
# enregistrement en variables
pg_host = config['pg_redadeg']['host']
pg_port = config['pg_redadeg']['port']
pg_db = config['pg_redadeg']['db'] + "_" + millesime
pg_user = config['pg_redadeg']['user']
pg_passwd = config['pg_redadeg']['passwd']
# chaîne de connexion Postgres
global PG_ConnString
PG_ConnString = "host="+ pg_host + " port="+ pg_port +" dbname="+ pg_db +" user="+ pg_user +" password="+ pg_passwd
#print(PG_ConnString)
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
def main():
# variables globales
global millesime
global PG_ConnString
# millesime forcé
millesime = "2022"
initVariables()
# connection à la base
try:
# connexion à la base, si plante, on sort
conn = psycopg2.connect(PG_ConnString)
cursor = conn.cursor()
except:
print( "connexion à la base impossible")
# déconnection de la base
try:
cursor.close()
conn.close()
except:
print("")
print( "")
print( " F I N")
return
if __name__ == "__main__":
# execute only if run as a script
main()