frappe-syntax-query-builder

Build secure Frappe database queries using the frappe.qb API.

163|53|Updated Jan 14, 2026
One-click install
npx skills add https://github.com/Impertio-Studio/Frappe_Claude_Skill_Package --skill frappe-syntax-query-builder-impertio-studio
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: frappe-syntax-query-builder
Source: https://github.com/Impertio-Studio/Frappe_Claude_Skill_Package/tree/main/skills/source/syntax/frappe-syntax-query-builder
Command: npx skills add https://github.com/Impertio-Studio/Frappe_Claude_Skill_Package --skill frappe-syntax-query-builder-impertio-studio

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill prevents production-breaking Frappe query code by guiding you to use frappe.qb correctly instead of raw SQL patterns that can fail silently or create DB-specific bugs.

Core Features & Use Cases

  • Robust query-building with frappe.qb: Covers SELECT, INSERT, UPDATE, DELETE, joins, aggregation, and subqueries using DocType and Field references.
  • Cross-database compatibility: Uses ImportMapper to switch DB-specific functions for MariaDB vs PostgreSQL while keeping one code path.
  • SQL-injection-safe execution guidance: Enforces running qb queries via .run() and avoids bypassing parameterization through frappe.db.sql(query.get_sql()).

Quick Start

Ask the AI to generate a frappe.qb query in Frappe v14-v16 that selects fields from a DocType, joins its child table, applies filters safely, runs as_dict=True, and uses ImportMapper for any DB-specific functions.

Frequently Asked Questions about frappe-syntax-query-builder

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build a cross-DB Frappe query that works on both MariaDB and PostgreSQL?

To build a cross-DB Frappe query, use the frappe.qb API with ImportMapper to map DB-specific functions, ensuring your code runs correctly on both MariaDB and PostgreSQL without raw SQL.

How do I join a DocType and its child table safely using frappe.qb?

You can join a DocType and its child table safely by using frappe.qb DocType and Field references instead of raw SQL. This parameterized query builder prevents SQL injection and avoids DB-specific bugs.

Why should I avoid passing frappe.qb queries into frappe.db.sql?

Passing frappe.qb queries into frappe.db.sql bypasses parameterization and exposes your application to SQL injection. You should always execute frappe.qb queries directly via the .run() method.

What is the best way to migrate from frappe.db.get_all to frappe.qb?

Migrating from frappe.db.get_all to frappe.qb involves using PyPika-based query builders for SELECT, INSERT, UPDATE, and DELETE operations. This enforces parameterized execution via .run() and prevents silent failures.

Does frappe.qb support subqueries and aggregates?

Yes, frappe.qb supports subqueries and aggregates. By leveraging the PyPika-based API, you can construct complex aggregations and nested queries using DocType and Field references securely.