How to use Table name with `back quote` as parameter

table_name = “tabSales Order

frappe.db.sql(""" Select * from %s “”", (table_name))

It errors dbname.’tabSales Order’ as it added single quote.

I cannot have backquote displayed here.

frappe.db.sql("select * from `tab{0}`".format('Sales Order'))
2 Likes

Thank you so much @saurabh6790.

If there are no complex condition match, use frappe.get_list(doctype, fields, filters)

example:

# simple dict filter
frappe.get_list("ToDo", fields=["name", "description"], filters = {"owner":"test@example.com"})

# filter as a list of lists
frappe.get_list("ToDo", fields="*", filters = [["modified", ">", "2014-01-01"]])

# filter as a list of dicts
frappe.get_list("ToDo", fields="*", filters = {"description": ("like", "test%")})
3 Likes

It’s really helpful, thanks again.
I was looking for kinda document like that but no luck.

You saved my day. :smile: