I need to do big queries from AWS Athena (500K+). If my query result have X rows and I use fetchmany to get Y rows at a time until I get all of my rows is it connecting to the db for every use of fetchmany? I ask because in Athena every query cost money and i prefer to do one big query instead of multiple smaller ones. Thanks.
def get_df
while sum_fetch < limit
batch_result = pd.DataFrame(cursor.fetchmany(FETCH_SIZE), columns=COLUMN_NAMES)
df = df.append(pd.DataFrame(batch_result))
sum_fetch += FETCH_SIZE
return df
if someone has a nicer way to do it it's also be great (i thought of maybe using a decorator to do the sum)