Reputation: 983
I'm writing a python package which provides functionality to get data from a website and process it. After processing, it should remember this specific data so that it doesn't try to process it again, even after restarting the script.
How would I implement saving this data persistently (by only saving an id)? I thought about providing a sqlite3 database file with my package. Would that be possible to access somehow? Or is there another, easier way that I don't see?
Upvotes: 0
Views: 52
Reputation: 1055
If you want to store data locally you can just serialise as a pickle object. Super fast read and writes would store the data between runs. https://docs.python.org/3.4/library/pickle.html
with open('persist.p','wb') as f:
pickle.dump(object,f)
with open('persist.p','rb') as f:
object = pickle.load(f)
Python docs on persistence here.
Upvotes: 1