title: Running a scripts that picks up from where it left off - Python
body: <p>I am working on a python script that puts information of a large number of ids to a mongo database. My scripts iterate through these ids and add them to the database based on today's date. However, the number of ids are too many and the script take many hours to run and iterate over all the ids.</p>
  
  <p>Let's say I start running the script today and runs till tomorrow but somehow fails before finishing. I wanted to ask if there's a way for me to make sure that the script runs from where it left off, instead of starting again from the beginning. I want to do this because firstly, I don't want duplicate values in the database, because now these ids will be added to the database based on tomorrow's date, thus differentiating them from today. And secondly, it is a waste of time to start the loop of the ids from beginning.</p>
  
  <p>Basically, I'm trying to find an answer for something like this <a href="https://stackoverflow.com/questions/20433992/how-can-i-create-a-script-that-picks-up-where-it-left-off-in-case-of-failure">How can I create a script that picks up where it left off in case of failure?</a>, but for Python.</p>