From f4e42f9256b53db5e63332dddce7be1d33aec4e8 Mon Sep 17 00:00:00 2001 From: krateng Date: Wed, 6 Apr 2022 16:48:02 +0200 Subject: [PATCH] Added database feedback when trying to add duplicate scrobbles --- maloja/database/sqldb.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/maloja/database/sqldb.py b/maloja/database/sqldb.py index a3a1063..054325f 100644 --- a/maloja/database/sqldb.py +++ b/maloja/database/sqldb.py @@ -245,12 +245,18 @@ def add_scrobbles(scrobbleslist,dbconn=None): ) for s in scrobbleslist ] - + success,errors = 0,0 for op in ops: try: dbconn.execute(op) - except sql.exc.IntegrityError: - pass + success += 1 + except sql.exc.IntegrityError as e: + errors += 1 + + # TODO check if actual duplicate + + if errors > 0: log(f"{errors} Scrobbles have not been written to database!",color='red') + return success,errors ### these will 'get' the ID of an entity, creating it if necessary