What problem does it solve?
Many Python projects mishandle database interactions, causing connection leaks, SQL injection risks, inefficient queries, and brittle migrations; this skill consolidates best practices for safe, predictable database access and ORM usage so developers can read and write data reliably.
Core Features & Use Cases
- Engine and connection pooling patterns including singletons and SQLite development config to avoid resource exhaustion.
- SQLAlchemy ORM model design, relationship handling, and metadata management for robust schema definitions.
- CRUD and transaction patterns using Session context managers, session.commit/refresh semantics, and soft-delete recommendations.
- Secure raw SQL usage with parameterized queries to prevent SQL injection and examples of migrations guidance (use Alembic in production).
- Pandas ↔ database workflows for bulk inserts and reads, and async database access patterns using async SQLAlchemy and AsyncSession.
- Common pitfalls and mitigations such as N+1 query avoidance, expire_on_commit implications, and thread-safety considerations.
Quick Start
Create a single Engine with get_engine(), use with Session() context managers, and execute parameterized queries to fetch or persist user data safely.