erpnext-database

Guide ERPNext database interactions across ORM, queries, and raw SQL.

163|53|Updated Jan 14, 2026
One-click install
npx skills add https://github.com/OpenAEC-Foundation/ERPNext_Anthropic_Claude_Development_Skill_Package --skill erpnext-database
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: erpnext-database
Source: https://github.com/OpenAEC-Foundation/ERPNext_Anthropic_Claude_Development_Skill_Package/tree/main/skills/source/core/erpnext-database
Command: npx skills add https://github.com/OpenAEC-Foundation/ERPNext_Anthropic_Claude_Development_Skill_Package --skill erpnext-database

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

ERPNext database operations can be complex, and teams often struggle with choosing the right abstraction level, writing efficient queries, and maintaining data integrity across ERPNext/Frappe apps.

Core Features & Use Cases

  • High-level ORM patterns for document CRUD and validations with frappe.get_doc and frappe.new_doc
  • Mid-level querying with frappe.db.get_list and frappe.db.get_value, plus safe batch operations
  • Low-level SQL access with frappe.db.sql and Query Builder for advanced reports
  • Transaction control, caching patterns, and best practices to avoid common ERPNext data pitfalls
  • Use cases: building robust ERPNext apps, optimizing data access, and preventing N+1 queries

Quick Start

Start by reviewing ERPNext database patterns in your project and implement the recommended abstraction levels for your use cases.

Frequently Asked Questions about erpnext-database

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

FAQPage Schema
What's the best way to structure ERPNext database queries for performance?

The best way to structure ERPNext database queries is by choosing the correct abstraction level, using frappe.db.get_list for mid-level reads, and applying batching and caching patterns to prevent N+1 query issues and optimize data access.

How do I use frappe.db.sql safely for raw SQL in Frappe apps?

To use frappe.db.sql safely, enforce safe SQL usage by parameterizing queries and restricting raw SQL access to advanced reporting tasks where the Query Builder or ORM cannot achieve the required complex data reads.

When should I use frappe.get_doc versus frappe.db.get_value in ERPNext?

Use frappe.get_doc for high-level ORM patterns involving document CRUD and validations, whereas frappe.db.get_value is intended for mid-level querying when you only need specific field values without loading the entire document object.

How do I handle transaction control safely in an ERPNext app?

Handle ERPNext transaction control safely by applying proper transaction controls, batching operations, and utilizing caching patterns to maintain data integrity across Frappe apps during complex document operations and database interactions.