import psycopg2 as psy
import pandas as pd
import getpass

def ecritureBDD(typeMem,addresse,valeur,connec):
    co = None
    try:
        co = psy.connect(host=connec[0],database=connec[1],user=connec[2],password=connec[3])
        cur = co.cursor()
        cur.execute("INSERT INTO Status VALUES (%s,%s,%s ) ON CONFLICT (addresse,type) DO UPDATE SET valeur=%s;",(addresse,typeMem,valeur,valeur))
        co.commit()
        cur.close()
    except(Exception,psy.DatabaseError) as error:
        print(error)
    finally:
        if co is not None:
            co.close()
