From 1db528b7c474ca59df91609bcd6e2b3e7d0d2c9d Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Sat, 11 Apr 2009 17:05:01 +0200 Subject: [PATCH] entropy.db: improve speed of doesColumnInTableExist --- libraries/entropy/db.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/libraries/entropy/db.py b/libraries/entropy/db.py index 8c36b8fb4..7a44635fe 100644 --- a/libraries/entropy/db.py +++ b/libraries/entropy/db.py @@ -3859,16 +3859,11 @@ class LocalRepository: return True def doesColumnInTableExist(self, table, column): - self.cursor.execute('PRAGMA table_info( '+table+' )') - rslt = self.cursor.fetchall() - if not rslt: - return False - found = False - for row in rslt: - if row[1] == column: - found = True - break - return found + self.cursor.execute('PRAGMA table_info( %s )' % (table,)) + rslt = (x[1] for x in self.cursor.fetchall()) + if column in rslt: + return True + return False def database_checksum(self, do_order = False, strict = True, strings = False):