import psycopg2 as psy
import pandas as pd
import getpass

def verifRegle(a):
    return True

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