PyPika Select static field

select name, amount, 30 as days from Salary Component

is any equivalent code in PyPika

salcmp = frappe.qb.DocType(“Salary Component”)
data = (frappe.qb.from_(salcmp)
.select(salcmp.name,salcmp.amount, (30).as_(‘days’))
.run(as_dict=True))

Hi @jayakumar:

from frappe.query_builder import Field
from frappe.query_builder.terms import ValueWrapper

salcmp = frappe.qb.DocType(“Salary Component”)
data = (frappe.qb.from_(salcmp).select(Field("name"),Field("amount"), ValueWrapper(30).as_("days"))).run(as_dict=True)

Hope this helps.

1 Like