Frappe.get_value vs frappe.db.get_value

I just realized both works slightly differently as below. Please confirm my understanding.

  1. frappe.get_value/set_value REQUIRES the docname to look up the value.
  2. frappe.db.get_value/set_value allows you to define the filter clause (like SQL WHERE with/without index) to lookup/set the value.

Pretty useful when you don’t know the name of the doc and want to lookup/set the fields.

e.g. parent doctype = bill, child doctype = bill tax. I wanted to set value of specific bill tax of a known bill.

It helped me to lookup name of the child table row (bill tax) by a second column (tax name) for which I only knew the parent name of the doc (bill).

1 Like

@aakvatech

what want to do please explain with the help of screenshots.

https://github.com/frappe/frappe/blob/87f41b8b0e9f05e76891661f6f517d2141a8b71b/frappe/init.py#L1293

I think get_value too works same it accepts filters apart from primary key as well its just an alias.

So essentially it is one and the same. Just the option of passing filters was not clear to me.