def commit(prefix_name: Optional[str])
The commit function saves all data changes and make them persistent.
This action finalizes the current open transaction, ensuring your data is durable and consistent.
💡
Is commit() always necessary?
Not usually. By default, dbzero has autocommit enabled, which saves changes automatically. You typically don't need to call commit() yourself.
However, calling it explicitly is useful when you're batching many operations for performance or need to guarantee that data is persisted at a specific point in your code's logic before proceeding.
Parameters
prefix_namestr, optional
Specific data prefix to commit. If omitted, commits changes for all open prefixes.
Returns
This method does not return any value.
Examples
Basic Usage
Create an object and commit it manually.
# Create a new object in memory
task = MemoTask(type="ingest", processor_type="p1")
# Explicitly save the new object to disk
db0.commit()Committing to a Specific Prefix
If your application uses multiple partitions, you can target a specific one for the commit operation.
# Open a second data store identified by a prefix
db0.open("archive_db")
# Create an object associated with the archive prefix
archived_task = MemoTask(type="archive", processor_type="archiver", prefix="archive_db")
# Commit only the changes for the "archive_db"
db0.commit("archive_db")