Positional fix: OperationalError before general

feature-admin-split
Darksider3 5 years ago
parent 77a31a44d1
commit 91b5e6ae7b

@ -85,15 +85,17 @@ class SQLitedb:
self.cursor.execute(qq, deliver) self.cursor.execute(qq, deliver)
self.last_result = self.cursor.fetchall() self.last_result = self.cursor.fetchall()
self.connection.commit() self.connection.commit()
except sqlite3.Error as e:
print("Couldn't execute query %s, exception: %s" % (qq, e), file=stderr)
self.last_result = []
except TypeError as e: except TypeError as e:
print("Types in given tuple doesnt match to execute query \"%s\": %s" % (qq, e), file=stderr) print("Types in given tuple doesnt match to execute query \"%s\": %s" % (qq, e), file=stderr)
self.last_result = [] self.last_result = []
except sqlite3.OperationalError as e: except sqlite3.OperationalError as e:
self._createTable() self._createTable()
return self.safequery(qq, deliver) return self.safequery(qq, deliver)
except sqlite3.Error as e:
print("Couldn't execute query %s, exception: %s" % (qq, e), file=stderr)
print(deliver)
print(type(e))
self.last_result = []
return self.last_result return self.last_result
def removeApplicantFromDB(self, userid: int) -> bool: def removeApplicantFromDB(self, userid: int) -> bool:
@ -107,13 +109,13 @@ class SQLitedb:
try: try:
self.last_result = self.cursor.execute("DELETE FROM `applications` WHERE id = ? ", [userid]) self.last_result = self.cursor.execute("DELETE FROM `applications` WHERE id = ? ", [userid])
self.connection.commit() self.connection.commit()
except sqlite3.Error as e:
print(f"Could not delete user with id: {userid}, exception in DB: {e}") # @TODO LOGGING FFS
return False
except sqlite3.OperationalError: except sqlite3.OperationalError:
print("The database has probably not yet seen any users, so it didnt create your table yet. Come back" print("The database has probably not yet seen any users, so it didnt create your table yet. Come back"
"when a user tried to register") "when a user tried to register")
return False return False
except sqlite3.Error as e:
print(f"Could not delete user with id: {userid}, exception in DB: {e}") # @TODO LOGGING FFS
return False
return True return True
def removeApplicantFromDBperUsername(self, username: str) -> bool: def removeApplicantFromDBperUsername(self, username: str) -> bool:
@ -127,13 +129,13 @@ class SQLitedb:
try: try:
self.last_result = self.cursor.execute("DELETE FROM `applications` WHERE username = ?", [username]) self.last_result = self.cursor.execute("DELETE FROM `applications` WHERE username = ?", [username])
self.connection.commit() self.connection.commit()
except sqlite3.Error as e:
print(f"Could not delete user {username}, exception in DB: {e}") # @TODO LOGGING
return False
except sqlite3.OperationalError: except sqlite3.OperationalError:
print("The database has probably not yet seen any users, so it didnt create your table yet. Come back" print("The database has probably not yet seen any users, so it didnt create your table yet. Come back"
"when a user tried to register") "when a user tried to register")
return False return False
except sqlite3.Error as e:
print(f"Could not delete user {username}, exception in DB: {e}") # @TODO LOGGING
return False
return True return True
def _createTable(self): def _createTable(self):

Loading…
Cancel
Save