How can I see the generated SQL query of a frappe.db.get_list method?

Dear frappers,

I want to see the SQL query generated by the frappe.db calls. For example:

a = frappe.db.get_list('Category')
print(a)

I understand that the Query Builder provides functionality like this:

query = frappe.qb.from_('Customer').select('id', 'fname', 'lname', 'phone')
str(query)
# SELECT "id","fname","lname","phone" FROM "tabCustomer"
query.get_sql()

I’m curious if frappe.db has a similar feature for viewing the SQL query it generates.

Thank you for your help!


@thinkdigital what’s wrong with print(a) , can’t you see the result of your query ?

Hi @thinkdigital:

Use Recorder.
https://frappeframework.com/docs/user/en/profiling

Hope this helps.

1 Like

Thank you for your response. I didn’t have any issues with that statement. I was trying to apply multiple filters, but all the conditions are set to ‘AND’ mode. I need some filters to use ‘AND’ while others should use ‘OR’. I thought checking the SQL query might provide better understanding.

for example:
frappe.db.get_list(doctype, multiple_filters, or_filters, fields, order_by, group_by, start, page_length)

Thank you @avc
Highly appreciate your help