def METHOD_NAME():
    conn = op.get_bind()
    start_time = time.time()
    # Loop through all certificates that are valid today or expired in the last 30 days.
    for cert_id, body in conn.execute(
            text(
                "select id, body from certificates where not_after > CURRENT_DATE - 31 and key_type is null")
    ):
        try:
            cert_key_type = utils.get_key_type_from_certificate(body)
        except ValueError as e:
            log.error("Error in processing certificate - ID: %s Error: %s \n" % (cert_id, str(e)))
        else:
            log.info("Processing certificate - ID: %s key_type: %s\n" % (cert_id, cert_key_type))
            stmt = text(
                "update certificates set key_type=:key_type where id=:id"
            )
            stmt = stmt.bindparams(key_type=cert_key_type, id=cert_id)
            op.execute(stmt)
            commit()
    log.info("--- %s seconds ---\n" % (time.time() - start_time))