AI-as-an-API-Course-Reference icon indicating copy to clipboard operation
AI-as-an-API-Course-Reference copied to clipboard

It export no rows if there are less than fetch_size rows in DB.

Open molinavinicius opened this issue 3 years ago • 0 comments

https://github.com/codingforentrepreneurs/AI-as-an-API-Course-Reference/blob/4f1249fff43da935d1be8f67d9d65c348db4c33a/app/main.py#L78

Suggest you change this part to:


def fetch_rows(
        stmt:SimpleStatement, 
        fetch_size:int = 25, 
        session=None):
    stmt.fetch_size = fetch_size
    result_set = session.execute(stmt)
    yield "uuid,label,confidence,query,version\n"
    while True:
        for row in result_set.current_rows:
            yield f"{row['uuid']},{row['label']},{row['confidence']},{row['query']},{row['model_version']}\n"
        if not result_set.has_more_pages:
            break
        result_set = session.execute(stmt, paging_state=result_set.paging_state)

or some similar strategy.

best regards.

molinavinicius avatar Aug 15 '22 00:08 molinavinicius