How to save the cursor location locally when python traverses mongodb

there is a requirement in the project that a field extracted from the mongodb library at the level of tens of millions of records needs to be transferred to postgresql.
because the mongodb is constantly updated, the data needs to be reversed at regular intervals. So I want to achieve the function of incremental update.
the question is, how do I save the location where I traversed the last python?

The _ id field of

ps:mongodb is automatically generated, and the other fields do not have a strict increasing or decreasing quantity relationship.

Mar.03,2021

if the _ id field in the document is automatically generated by mongo, then the field itself has a timing, because the ObjectId four elements
have insertion time, nothing is written in the query statement, and the result is sorted in chronological order. The following statement returns the last 10 pieces of data in collection:

  python datetime 

					
Menu