sqlalchemy_skill

This skill helps you design and optimize SQLAlchemy ORM patterns, sessions, and queries for fast, scalable PostgreSQL-backed support systems.
  • Shell

40

GitHub Stars

4

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill manutej/luxor-claude-marketplace --skill sqlalchemy

  • .summary.txt4.2 KB
  • EXAMPLES.md84.4 KB
  • README.md17.4 KB
  • SKILL.md30.0 KB

Overview

This skill is a practical, hands-on guide for using SQLAlchemy 2.0+ to build and operate customer support systems. It covers ORM model design for tickets, users, comments, tags, plus session management, query optimization, async FastAPI integration, and PostgreSQL best practices. The focus is real-world patterns that improve reliability, performance, and maintainability of support applications.

How this skill works

The skill inspects common support-domain data models and provides idiomatic SQLAlchemy declarative mappings with type hints, relationship patterns, and association tables. It describes synchronous and asynchronous engine/session configuration, context-managed session usage, and FastAPI dependency patterns. It also demonstrates query optimization (joinedload/selectinload), advanced filtering, pagination, and aggregation queries for analytics.

When to use it

  • Designing data models for tickets, users, comments, attachments, and tags in a support app.
  • Integrating SQLAlchemy with FastAPI using async sessions and asyncpg.
  • Preventing N+1 query problems and tuning eager loading strategies for performance.
  • Implementing robust session lifecycle, connection pooling, and error handling.
  • Building complex search, filtering, pagination, and analytics queries against PostgreSQL.

Best practices

  • Use DeclarativeBase with mapped_column and type hints for clear, maintainable models.
  • Choose joinedload for single-row relations and selectinload for large collections to avoid N+1 queries.
  • Keep expire_on_commit=False to avoid unnecessary reloading in web request lifecycles when appropriate.
  • Use connection pool settings (pool_pre_ping, pool_size, max_overflow) tuned for your traffic patterns.
  • Use soft-delete (deleted_at) filters consistently and include them in query builders.

Example use cases

  • Fetch tickets with creator, assignee, comments, attachments, and tags in a single optimized query for a support UI.
  • Implement a FastAPI dependency that yields an AsyncSession and correctly commits or rolls back on exceptions.
  • Build an advanced search endpoint that supports full-text-like filters, status/priority lists, tag filters, and paginated results.
  • Create dashboards with aggregation queries returning counts, trends, and SLA-related metrics grouped by date or status.
  • Model many-to-many tags with an association table that records metadata like created_at.

FAQ

Use joinedload for many-to-one or one-to-one relationships where the join cost is small. Use selectinload for large collections to fetch related rows in separate IN queries and avoid row multiplication.

How do I manage transactions in web requests?

Use a context manager for sync sessions or a dependency that yields an AsyncSession in FastAPI. Commit after successful work, rollback on exceptions, and always close the session to return connections to the pool.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
sqlalchemy skill by manutej/luxor-claude-marketplace | VeilStrat