|
@@ -117,12 +117,13 @@ DATABASE = {'host': args.dbhost,
|
|
|
DATE_FROM = parse_date(args.from_date) if args.from_date else date.today()
|
|
|
DATE_TO = parse_date(args.to_date) if args.to_date else date.today()
|
|
|
|
|
|
-conn = psycopg2.connect(**DATABASE)
|
|
|
-cursor = conn.cursor()
|
|
|
data = download_data()
|
|
|
+if not data:
|
|
|
+ quit(0)
|
|
|
|
|
|
-if data:
|
|
|
- cursor.execute(f"DELETE FROM consumpties_{args.dbuser} WHERE datum BETWEEN %s AND %s", (DATE_FROM, DATE_TO))
|
|
|
+conn = psycopg2.connect(**DATABASE)
|
|
|
+cursor = conn.cursor()
|
|
|
+cursor.execute(f"DELETE FROM consumpties_{args.dbuser} WHERE datum BETWEEN %s AND %s", (DATE_FROM, DATE_TO))
|
|
|
|
|
|
for product, consumptie in extract_consumpties(data):
|
|
|
insert_product(cursor, **product)
|