How Do I Set Paging Query with Python?
Using Paging Query
The fetch size controls how many rows will be fetched per page.
query = "SELECT * FROM space3.table3;" # table3 contains 100 rows statement = SimpleStatement(query, fetch_size=10)
After the setting is successful, for all sessions spawned with this configuration, 10 rows are fetched from the server at a time. When the cache (10 rows) is exhausted, the system triggers a request for fetching another 10 rows from the server and there can be a waiting period.
result = session.execute(statement) # Print the number of current cache rows. The number is 10. print(result.current_rows) # The next page is automatically obtained. for row in result: print(row)
Saving and Reusing the Paging State
- Save the current paging state.
# Save the paging status. web_session['paging_stage'] = results.paging_state
- Load and reuse the current paging state.
statement = SimpleStatement(query, fetch_size=10) ps = web_session['paging_state'] results = session.execute(statement, paging_state=ps)
For more advanced usage and introduction, see Paging Large Queries.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot