How to use frappe.db.sql on print format .. is it Possible?

Yes I Found This Solution this way Because frappe.db.sql is not working on print format but frappe.get_all() , get_value(). its working

				{% set qty_in_kgs_total = [0] %}
				{% set balance_total=[0] %}
				{% set imp_qnty=[0] %}

				{%- for row in doc.yarn_description -%}
					
					{% set _ = qty_in_kgs_total.append(qty_in_kgs_total.pop() + row.qnty_in_kgs|int) %}

					{% set _ = balance_total.append(balance_total.pop()+row.balance|int ) %}
					{% set _ =imp_qnty.append(imp_qnty.pop()+row.imp_qnty|int ) %}
					<tr> 
						<td>{{row.idx}}</td>
						<td>{{row.yarn_specification}}</td>
						<td>{{row.qnty_in_kgs}}</td>
						<td>{% if row.imp_qnty %}   {{row.imp_qnty}}  {% endif %}</td>
						<td>{% if row.b2b_lc_no %} {{row.b2b_lc_no}} {% endif %}</td>
						<td>{% if row.mills %} {{row.mills}} {% endif %}</td>
						<td>{{row.balance}}</td>
						<td>{% if row.remarks %} {{row.remarks}} {% endif %}</td>
					</tr>
				{%- endfor -%}

					<tr>
						<td></td>
						<td>Total :-</td>
						<td>{{ qty_in_kgs_total[0] }}</td>
						<td>{{ imp_qnty[0] }}</td>
						<td></td>
						<td></td>
						<td>{{balance_total[0]}}</td>
						<td></td>
					</tr>
				</tbody>
			</table>

:slight_smile::grinning:

Sl No Yarn Description Qnty in Kgs. Imp Qnty. B2B L/C no Mills Balance Remark