From 176e69ffd891acd1ebdf0b9199dc111e7732a246 Mon Sep 17 00:00:00 2001 From: CMDR furrycat Date: Fri, 18 Nov 2016 17:33:35 +0000 Subject: [PATCH] Handle cursor being None. --- db.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/db.py b/db.py index bffab1d..b7664ac 100644 --- 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 -- 2.7.4