{"enrichment":{"faq":[{"a":"SQLAlchemy equips Python developers with a robust SQL toolkit and ORM for building type-safe database applications. You query using the modern 2.0 API with `select()` statements, define models as declarative classes inheriting from `DeclarativeBase`, and execute queries through sessions. SQLAlchemy handles SQL generation, relationship mapping, and database abstraction across multiple backends.","q":"What is SQLAlchemy and how do I query with it?"},{"a":"SQLAlchemy integrates with FastAPI by creating a database engine, configuring a session factory, and injecting sessions into route handlers via dependency injection. Define your models using declarative syntax, create async sessions with `AsyncSession`, and use them in FastAPI endpoints to perform CRUD operations. This pattern keeps your routes clean and testable.","q":"How do I use SQLAlchemy with FastAPI?"},{"a":"SQLAlchemy 2.0 uses the `select()` constructor for composable queries. Basic example: `select(User).where(User.age > 18)`. Join multiple tables with `select(User, Post).join(Post)`. Filter with `.where()`, order with `.order_by()`, and limit results with `.limit()`. The API is chainable and type-safe, replacing the legacy query interface.","q":"What are SQLAlchemy 2.0 select query examples?"},{"a":"SQLAlchemy's N+1 problem occurs when loading related objects triggers extra queries. Solve it using eager loading strategies: `selectinload()` executes a second query to load relationships, `joinedload()` uses a single JOIN, and `contains_eager()` works with explicit joins. Import from `sqlalchemy.orm` and apply to your select: `select(User).options(selectinload(User.posts))`.","q":"How do I solve the SQLAlchemy N+1 problem with eager loading?"},{"a":"SQLAlchemy works with Alembic for schema management. Initialize Alembic with `alembic init`, configure your database URL in `alembic.ini`, and set `sqlalchemy.url`. Define your models, then auto-generate migrations with `alembic revision --autogenerate -m 'message'`. Review the generated migration file, then apply changes with `alembic upgrade head`.","q":"How do I set up database migrations with Alembic?"},{"a":"SQLAlchemy session management best practices include using context managers (`with Session() as session:`), keeping sessions scoped to request lifecycles in web apps, avoiding session sharing across threads, and committing or rolling back explicitly. Use `sessionmaker` to create a factory, configure connection pooling for performance, and always close sessions to return connections to the pool.","q":"What are SQLAlchemy session management best practices?"}],"shadow_tags":["object-relational-mapping","database-abstraction-layer","async-database-access","schema-versioning","connection-pooling","query-optimization","data-persistence","orm-relationships","migration-management","type-safe-queries"],"summary_rewrite":"SQLAlchemy equips Python developers with a robust SQL toolkit and ORM for building type-safe database applications. Master declarative models, relationship mapping, efficient query patterns, and async support using SQLAlchemy 2.0's modern API."},"files":[{"bytes":26936,"path":"toolchains/python/data/sqlalchemy/SKILL.md","sha256":"4ce69ba775e5c954a7201e1e4dc3863201ebd0887c64ea47efccbacc9b14631a","url":"https://skillfed.io/files/bobmatnyc/claude-mpm-skills/sqlalchemy/1f55dbdf/SKILL.md"}],"id":"bobmatnyc/claude-mpm-skills/sqlalchemy","links":{"html":"https://skillfed.io/bobmatnyc/claude-mpm-skills/sqlalchemy","md":"https://skillfed.io/bobmatnyc/claude-mpm-skills/sqlalchemy.md","repo":"https://github.com/bobmatnyc/claude-mpm-skills"},"meta":{"agents_supported":[],"first_seen":"2026-07-28","forks":18,"language":"Python","last_updated":"2026-07-18","license":"MIT","name":"sqlalchemy","publisher":"bobmatnyc","stars":62},"relations":{"similar":[{"id":"majesticlabs-dev/majestic-marketplace/sqlalchemy-patterns"},{"id":"manutej/luxor-claude-marketplace/sqlalchemy"},{"id":"hieutrtr/ai1-skills/python-backend-expert"},{"id":"personamanagmentlayer/pcl/python-expert"},{"id":"martinholovsky/claude-skills-generator/fastapi-expert"},{"id":"alinaqi/maggy/supabase-python"},{"id":"manutej/luxor-claude-marketplace/fastapi"},{"id":"martinholovsky/claude-skills-generator/python"},{"id":"cfircoo/claude-code-toolkit/sqlalchemy-postgres"},{"id":"CuriousLearner/devkit/query-builder"}]},"slug":{"owner":"bobmatnyc","repo":"claude-mpm-skills","skill":"sqlalchemy"},"version":"1f55dbdf"}
