Returns `n` rows from the table's start or end
    :param dbconn: database connection
    :param tablename: name of the table
    :param n: number of rows to return from the end of the table
    :param uuid: Optional UUID to select from
    :return: If n > 1, a list of rows. If n=1, a single row

def fetch(dbconn, tablename, n=1, uuid=None, end=True):
    """
    Returns `n` rows from the table's start or end
    :param dbconn: database connection
    :param tablename: name of the table
    :param n: number of rows to return from the end of the table
    :param uuid: Optional UUID to select from
    :return: If n > 1, a list of rows. If n=1, a single row
    """
    cur = dbconn.cursor()
    order = 'DESC' if end else 'ASC'
    try:
        if uuid:
            cur.execute("SELECT * FROM '{}' WHERE UUID='{}' ORDER BY ROWID {} LIMIT {};".format(tablename, uuid, order, n))
        else:
            cur.execute("SELECT * FROM '{}' ORDER BY ROWID {} LIMIT {};".format(tablename, order, n))
    except sqlite3.OperationalError as e:
        if 'no such table' not in getattr(e, 'message', ''):
            # Suppress logging of errors generated when no table exists
            logger.error(e)
        return []
    rows = cur.fetchall()
    return rows