Getting value from single doctype

I found there are 2 ways to get value from single doctype using python:

frappe.get_single('System Settings').country,

frappe.db.get_single_value('System Settings', 'country'),

What are the difference?
What are the recommended one?

1 Like
  • The function get_single() returns a frappe.model.document.Document object. You can interact with the Document using all its methods.

  • The function get_single_value() calls the database directly, and returns a simple datatype. An integer, string, float, boolean, etc.

Which to use depends on your use-case.

1 Like

So to get only single field value would be better using the db call?