def _limit_and_df(self, query, limit, as_df=False):
if limit:<EOL><INDENT>if isinstance(limit, int):<EOL><INDENT>query = query.limit(limit)<EOL><DEDENT>if isinstance(limit, Iterable) and len(limit) == <NUM_LIT:2> and [int, int] == [type(x) for x in limit]:<EOL><INDENT>page, page_size = limit<EOL>query = query.limit(page_size)<EOL>query = query.offset(page * page_size)<EOL><DEDENT><DEDENT>if as_df:<EOL><INDENT>results = read_sql(query.statement, self.engine)<EOL><DEDENT>else:<EOL><INDENT>results = query.all()<EOL><DEDENT>return results<EOL>
adds a limit (limit==None := no limit) to any query and allow a return as pandas.DataFrame

        :param bool as_df: if is set to True results return as pandas.DataFrame
        :param `sqlalchemy.orm.query.Query` query: SQL Alchemy query 
        :param int or tuple[int] limit: maximum number of results
        :return: query result of pyuniprot.manager.models.XY objects