From 97a13b01b0eb64bdb128f3e1dcefe657b0d18b7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 2 Sep 2009 21:01:32 +0200 Subject: [PATCH] Prevent exception when testing SQLite database (corrupted file) --- trytond/backend/sqlite/database.py | 43 ++++++++++++++++-------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/trytond/backend/sqlite/database.py b/trytond/backend/sqlite/database.py index 8763f8b4b2..e66fb833f0 100644 --- a/trytond/backend/sqlite/database.py +++ b/trytond/backend/sqlite/database.py @@ -265,26 +265,29 @@ class Cursor(CursorInterface): self._conn.rollback() def test(self): - self.cursor.execute("SELECT name " \ - "FROM sqlite_master " \ - "WHERE type = 'table' AND name in (" \ - "'ir_model', " - "'ir_model_field', " - "'ir_ui_view', " - "'ir_ui_menu', " - "'res_user', " - "'res_group', " - "'wkf', " - "'wkf_activity', " - "'wkf_transition', " - "'wkf_instance', " - "'wkf_workitem', " - "'wkf_witm_trans', " - "'ir_module_module', " - "'ir_module_module_dependency, '" - "'ir_translation, '" - "'ir_lang'" - ")") + try: + self.cursor.execute("SELECT name " \ + "FROM sqlite_master " \ + "WHERE type = 'table' AND name in (" \ + "'ir_model', " + "'ir_model_field', " + "'ir_ui_view', " + "'ir_ui_menu', " + "'res_user', " + "'res_group', " + "'wkf', " + "'wkf_activity', " + "'wkf_transition', " + "'wkf_instance', " + "'wkf_workitem', " + "'wkf_witm_trans', " + "'ir_module_module', " + "'ir_module_module_dependency, '" + "'ir_translation, '" + "'ir_lang'" + ")") + except: + return False return len(self.cursor.fetchall()) != 0 def lastid(self):