<commit_before>"""
.. module: lemur.common.health
    :platform: Unix
    :copyright: (c) 2015 by Netflix Inc., see AUTHORS for more
    :license: Apache, see LICENSE for more details.

.. moduleauthor:: <NAME> <<EMAIL>>
"""
from flask import Blueprint

mod = Blueprint('healthCheck', __name__)


@mod.route('/healthcheck')
def health():
    return 'ok'<commit_msg>Add Check of DB connections on healthcheck URL (#812)<commit_after>"""
.. module: lemur.common.health
    :platform: Unix
    :copyright: (c) 2015 by Netflix Inc., see AUTHORS for more
    :license: Apache, see LICENSE for more details.

.. moduleauthor:: <NAME> <<EMAIL>>
"""
from flask import Blueprint
from lemur.database import db

mod = Blueprint('healthCheck', __name__)


@mod.route('/healthcheck')
def health():
    try:
        if healthcheck(db):
            return 'ok'
    except:
        return 'db check failed'


def healthcheck(db):
    with db.engine.connect() as connection:
        connection.execute('SELECT 1;')
    return True
{'fraction_non_alphanumeric': 0.13129318854886476, 'fraction_numerical': 0.011846001974333662, 'mean_word_length': 3.506666666666667, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5660127', 'n_tokens_mistral': 320, 'n_tokens_neox': 296, 'n_words': 103}