From c0f47cc8feb0cdfceb6868d41747520d7e1fdeed Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Sun, 27 Feb 2011 23:18:52 +0100 Subject: [PATCH] [entropy.db] EntropyRepository: rewrite _doesColumnInTableExist() to be more efficient --- libraries/entropy/db/__init__.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libraries/entropy/db/__init__.py b/libraries/entropy/db/__init__.py index 6c28208a3..f9c265938 100644 --- a/libraries/entropy/db/__init__.py +++ b/libraries/entropy/db/__init__.py @@ -5118,10 +5118,13 @@ class EntropyRepository(EntropyRepositoryBase): del cached return obj - cur = self._cursor().execute('PRAGMA table_info( %s )' % (table,)) - rslt = (x[1] for x in cur.fetchall()) - - exists = column in rslt + try: + self._cursor().execute(""" + SELECT `%s` FROM `%s` LIMIT 1 + """ % (column, table)) + exists = True + except OperationalError: + exists = False cached[d_tup] = exists self._setLiveCache("_doesColumnInTableExist", cached) # avoid python3.x memleak