def get_database_name(host_id):
    """Return DATABASE_NAME"""
    from physical.models import Host
    host = Host.objects.filter(id=host_id,
                               ).select_related('instance',
                                                ).select_related('databaseinfra',
                                                                 ).select_related('database',)

    try:
        host = host[0]
    except __HOLE__ as e:
        LOG.warn("Host id does not exists: {}. {}".format(host_id, e))
        return None

    try:
        database = host.instance_set.all()[0].databaseinfra.databases.all()[0]
    except IndexError as e:
        LOG.warn(
            "There is not a database on this host: {}. {}".format(host_id, e))
        return None

    return database.name
dataset/ETHPy150Open globocom/database-as-a-service/dbaas/maintenance/registered_functions/functools.py/get_database_name