-
Notifications
You must be signed in to change notification settings - Fork 537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Atomic update operation? #6
Comments
Hey phreeza! First about the
That would update all elements, where the I've implemented this Concerning the atomicity: At the moment |
that interface is exactly what I had in mind, great. I assume this would update all matches to the query correspondingly? I hadn't even gone as far as thinking about 'true' atomicity on the filesystem level. I think this will do just fine for my purposes. |
That's exactly what it does :) I'll publish the new version of |
I hope you don't mind me asking here: is the present |
That depends on how exactly you define atomicity. If you're looking for atomicity as used in the ACID acronym, TinyDB doesn't come with atomicity by default. As mentioned above, one could implement some sort of atomicity by writing data to a temporary file first and then renaming it to the actual file. But in general, TinyDB simply writes the whole database to disk on every write operation. If the Python interpreter dies or crashes mid-way, TinyDB doesn't provide any guarantees about data integrity out of the box (aside from a custom storage that provides a basic level of atomicity as mentioned above). |
Okay, thanks for clarifying. I think I'll go with tinyrecord, which as I understand, provides that. |
Not sure how hard this would be to implement, but it would be neat to have a safe way of updating an entry. Right now I am deleting and then inserting the new entry, which seems the only way to do this, but it is quite unsafe, for example if the program is terminated right between the write and delete steps the database may become corrupted.
If there is interest in this, I would be willing to put in some work, if someone can give me guidance. Does it fundamentally go against the philosophy, or would it make sense?
The text was updated successfully, but these errors were encountered: