""" Model for Healthcheck. This module contains functions to perform healthchecks on the DB. """ import os import raven from contracts.connectors import mysql def check_db(): """Perform a DB healthcheck. Returns: bool: True if db check passes, False otherwise. """ sql = 'SELECT "hello"' try: with mysql.db_session() as session: rs = session.execute(sql) result = rs.fetchone() return len(result) > 0 and result[0] == 'hello' except Exception: if os.environ.get('SENTRY_DSN'): raven.Client().captureException() return False