How to use frappe.db.commit in normal function calls

Hi friends,
we know that frappe.db.commit works with HTTP’s POST and PUT calls.
But I wanna use it in a function call from python.
Means, I save some documents, and then at the end of the function, I wanna use db.commit.
right now whenever I call save() it is saving doc in DB right away.
is there any way to save as a draft or something? and then call commit to save any pending saves and updates?