Commit d10e33ef authored by Jonathan Schaeffer's avatar Jonathan Schaeffer
Browse files

Ajout de message sur erreur

parent 1ca4b48e
......@@ -207,13 +207,24 @@ def cli(configfile, force_scan, dryrun, verbose, version):
host=cfg['postgres']['host'], password=cfg['postgres']['password'], port=cfg['postgres']['port'])
cur = conn.cursor()
for stat in statistics:
cur.execute(
"""
INSERT INTO dataholdings (network, year, station, channel, quality, type, size, is_permanent, volume, date)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
ON CONFLICT (network,year,station,channel,type,date) DO UPDATE SET size = EXCLUDED.size;
""",
(stat['network'], stat['year'], stat['station'], stat['channel'], stat['quality'], stat['type'], stat['size'], stat['is_permanent'], stat['volume'], stat['date']))
try:
cur.execute(
"""
INSERT INTO dataholdings (network, year, station, channel, quality, type, size, is_permanent, volume, date)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
ON CONFLICT (network,year,station,channel,type,date) DO UPDATE SET size = EXCLUDED.size;
""",
(stat['network'], stat['year'], stat['station'], stat['channel'], stat['quality'], stat['type'], stat['size'], stat['is_permanent'], stat['volume'], stat['date']))
except psycopg2.Error as err:
logging.error(err)
logging.info(cur.mogrify(
"""
INSERT INTO dataholdings (network, year, station, channel, quality, type, size, is_permanent, volume, date)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
ON CONFLICT (network,year,station,channel,type,date) DO UPDATE SET size = EXCLUDED.size;
""",
(stat['network'], stat['year'], stat['station'], stat['channel'], stat['quality'], stat['type'], stat['size'], stat['is_permanent'], stat['volume'], stat['date'])
))
conn.commit()
if __name__ == "__main__":
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment