From 4f7c63d5df15ed58f2d1313a46363aed785e4e09 Mon Sep 17 00:00:00 2001
From: angelblue05 <tamara.angel05@gmail.com>
Date: Fri, 4 Nov 2016 05:03:44 -0500
Subject: [PATCH] Raise errors other than database is locked

Remove old code
---
 resources/lib/database.py | 44 ++------------------------------
 resources/lib/utils.py    | 53 ---------------------------------------
 2 files changed, 2 insertions(+), 95 deletions(-)

diff --git a/resources/lib/database.py b/resources/lib/database.py
index fdb68b01..6e172143 100644
--- a/resources/lib/database.py
+++ b/resources/lib/database.py
@@ -87,51 +87,11 @@ class DatabaseConn(object):
             # Errors were raised in the with statement
             log.error("rollback: Type: %s Value: %s", exc_type, exc_val)
             self.conn.rollback()
-            raise
+            if not "database is locked" in exc_val:
+                raise
 
         elif self.commit_mode is not None:
             log.warn("commit: %s", self.path)
             self.conn.commit()
 
         self.conn.close()
-
-'''def query(execute_query, connection=None, conn_type=None, *args):
-    
-    """
-    connection is sqlite.connect
-    conn_type is only required if a connection is not provided
-    *args are tuple values that contain the corresponding data for the query
-    i.e     args_executemany = (('value1', 'value2'),('value1', 'value2'))
-            args_execute = ('value1', 'value2')
-    tip: to build args_executemany, build a list of sets [(v1,v2),(v1,v2)], then pass it as *args
-    """
-    
-    if connection is None:
-        if conn_type is None:
-            return False
-        else:
-            connection = DatabaseConn(conn_type)
-
-    attempts = 3
-    while True:
-        try:
-            with connection as conn:
-                # raise sqlite3.OperationalError("database is locked")
-                if not args:
-                    return conn.execute(query)
-                elif isinstance(args[0], tuple):
-                    # Multiple entries for the same query
-                    return conn.executemany(query, args)
-                else:
-                    return conn.execute(query, args)
-            
-        except sqlite3.OperationalError as e:
-            if "database is locked" in e:
-                # Database is locked, retry
-                attempts -= 1
-                xbmc.sleep(500)
-            else:
-                raise
-
-        if not attempts:
-            return False'''
diff --git a/resources/lib/utils.py b/resources/lib/utils.py
index e2495ef7..c306942d 100644
--- a/resources/lib/utils.py
+++ b/resources/lib/utils.py
@@ -169,59 +169,6 @@ def getKodiMusicDBPath():
                 % dbVersion.get(xbmc.getInfoLabel('System.BuildVersion')[:2], "")).decode('utf-8')
     return dbPath
 
-def querySQL(query, args=None, cursor=None, conntype=None):
-
-    result = None
-    manualconn = False
-    failed = False
-
-    if cursor is None:
-        if conntype is None:
-            log.info("New connection type is missing.")
-            return result
-        else:
-            manualconn = True
-            connection = kodiSQL(conntype)
-            cursor = connection.cursor()
-
-    attempts = 0
-    while attempts < 3:
-        try:
-            log.debug("Query: %s Args: %s" % (query, args))
-            if args is None:
-                result = cursor.execute(query)
-            else:
-                result = cursor.execute(query, args)
-            break # Query successful, break out of while loop
-        except sqlite3.OperationalError as e:
-            if "database is locked" in e:
-                log.warn("%s...Attempt: %s" % (e, attempts))
-                attempts += 1
-                xbmc.sleep(1000)
-            else:
-                log.error(e)
-                if manualconn:
-                    cursor.close()
-                raise
-        except sqlite3.Error as e:
-            log.error(e)
-            if manualconn:
-                cursor.close()
-            raise
-    else:
-        failed = True
-        log.info("FAILED // Query: %s Args: %s" % (query, args))
-
-    if manualconn:
-        if failed:
-            cursor.close()
-        else:
-            connection.commit()
-            cursor.close()
-
-    log.debug(result)
-    return result
-
 #################################################################################################
 # Utility methods