DataMount:query
methodDataMount:query(sql: string, params?: table) -> DataHandleBuild a DataHandle that runs sql against the mount when it is first read; nothing is sent before then. Errors raise where the handle is read; wrap that read in pcall to catch them. params is an integer-indexed table of bound values substituted into ? placeholders in order, or omitted for no parameters. Each value must be nil, boolean, integer, number, or string.
local sql = "SELECT region, total FROM orders WHERE year = ?"
local orders = sales:query(sql, { 2026 })
-- The query runs here, when the handle is first consumed.
print(orders:count())In the guide: Query and chart data