Handle cursor being None.
authorCMDR furrycat <elite@furrycat.net>
Fri, 18 Nov 2016 17:33:35 +0000 (17:33 +0000)
committerCMDR furrycat <elite@furrycat.net>
Fri, 18 Nov 2016 17:33:35 +0000 (17:33 +0000)
db.py

diff --git a/db.py b/db.py
index bffab1d..b7664ac 100644 (file)
--- a/db.py
+++ b/db.py
@@ -154,12 +154,15 @@ class DBConnection(object):
     params.append(id)
     sql = 'update {} set {} where bot_id=? and id=?'.format(table, ', '.join(['{}=?'.format(v) for v in values]))
     cursor = self.query(sql, params)
-    if cursor.rowcount:
-      self.commit()
-      ret = True
+    if cursor is not None:
+      if cursor.rowcount:
+        self.commit()
+        ret = True
+      else:
+        log.error('No such entry {} in {} table for {}'.format(id, table, client.user.name))
+        self.rollback()
+        ret = False
     else:
-      log.error('No such entry {} in {} table for {}'.format(id, table, client.user.name))
-      self.rollback()
       ret = False
     self.close_db()
     return ret