database-operations

Instructions on how to write database queries with SQLAlchemy.

⭐4stars🔀0forks📁View on GitHub🕐Updated Jan 8, 2026⬇️1downloads

When & Why to Use This Skill

This Claude skill provides expert guidance on crafting efficient and maintainable database queries using SQLAlchemy. It focuses on performance optimization by advocating for bulk operations and SQL joins over inefficient loops, while promoting clean code architecture through the implementation of repository classes. Ideal for developers looking to enhance database interaction performance and code organization in Python applications.

Use Cases

  • Optimizing data processing tasks by replacing Python-level for-loops with SQLAlchemy bulk operations to reduce database overhead.
  • Architecting scalable backend systems by encapsulating complex database logic within dedicated repository classes for better modularity.
  • Improving application response times by utilizing SQL joins to retrieve related datasets in a single query instead of multiple round-trips.
  • Refactoring legacy SQLAlchemy code to adhere to modern best practices for performance and maintainability.
namedatabase-operations
descriptionInstructions on how to write database queries with SQLAlchemy.

When performing database operations using SQLAlchemy, follow these guidelines to ensure efficient and maintainable code:

  • Avoid for-loops. Instead always prefer bulk operations using SQLAlchemy's built-in methods or use SQL joins to get related data in a single query.
  • Database operations should be contained in repository classes