diff --git a/SAS/MoM/MoMQueryService/momqueryservice.py b/SAS/MoM/MoMQueryService/momqueryservice.py index bfe2c7cfb5206c018773a476fbe7f311a89e23ee..d7d541d5c27da11083f5e0186e43c9464b255d0c 100755 --- a/SAS/MoM/MoMQueryService/momqueryservice.py +++ b/SAS/MoM/MoMQueryService/momqueryservice.py @@ -80,8 +80,11 @@ class MoMDatabaseWrapper: # try a simple select # if it fails, reconnect cursor = self.conn.cursor() - cursor.execute('''SELECT * FROM project;''') - cursor.fetchall() + cursor.execute('''SELECT id FROM project;''') + if len(cursor.fetchall()) == 0: + logger.warning('unexpected answer while checking connection. reconnecting in 1 sec...') + time.sleep(1) + self._connect() except (OperationalError, AttributeError) as e: if isinstance(e, OperationalError): logger.error(str(e))