database
Build Production-Ready Database Operations
Writing database code from scratch leads to connection leaks, slow queries, and migration headaches. This skill provides battle-tested patterns for async database operations, connection pooling, migrations, and performance optimization that work across PostgreSQL, MySQL, and SQLite.
Baixar o ZIP da skill
Upload no Claude
Vá em Configurações → Capacidades → Skills → Upload skill
Ative e comece a usar
Testar
A utilizar "database". Create a User model with email, username, full name, and is_active fields with proper indexes
Resultado esperado:
- Model includes email and username as unique indexed fields
- Uses Text for longer content like bio field
- Created_at and updated_at timestamps with server defaults
- Composite indexes for common query patterns
- Soft delete mixin available for logical deletion
A utilizar "database". Set up async PostgreSQL connection with connection pooling for production
Resultado esperado:
- Async engine created with postgresql+asyncpg driver
- Connection pool configured with pool_size=30 and max_overflow=40
- Pool_pre_ping enabled to detect stale connections
- Pool_recycle set to 3600 seconds for connection rotation
- Environment-based configuration for different environments
A utilizar "database". Write an Alembic migration to add a new table for user profiles
Resultado esperado:
- Migration file includes upgrade() and downgrade() functions
- Creates user_profiles table with user_id foreign key
- Adds unique index on user_id to enforce one-to-one relationship
- Includes proper column definitions with nullable constraints
Auditoria de Segurança
Baixo RiscoThis skill is pure documentation (SKILL.md only) containing database best practices and code examples. Static findings are false positives - the scanner detects SQLAlchemy's session.exec() method as Python exec(), database URLs in documentation as credential exposure, and hardcoded example strings as malicious patterns. No executable code, no network calls, no file operations exist in this skill.
Fatores de risco
🌐 Acesso à rede (1)
📁 Acesso ao sistema de arquivos (1)
⚡ Contém scripts (6)
⚙️ Comandos externos (23)
🔑 Variáveis de ambiente (5)
Pontuação de qualidade
O Que Você Pode Construir
Set up production database layer
Configure async connections, connection pooling, and migrations for a new Python web application.
Optimize query performance
Analyze slow queries, add proper indexes, and implement caching strategies for large datasets.
Configure production databases
Set up connection limits, monitoring, backup strategies, and security configurations.
Tente Estes Prompts
Create SQLModel models for a [entity name] with fields for [field descriptions], including timestamps, soft delete, and proper indexes.
Set up async database connection with SQLAlchemy including connection pooling for [development/production] with pool size [number] and max overflow [number].
Create a repository class for [model name] with methods for create, get, get_multi, update, remove, and count with proper async support.
Write an Alembic migration to [describe schema change] including upgrading and downgrading functions.
Melhores Práticas
- Always use async sessions with expire_on_commit=False for better performance
- Implement connection pooling with appropriate pool size based on expected concurrent users
- Add indexes on foreign keys and frequently filtered columns to optimize queries
Evitar
- Do not use synchronous database calls in async FastAPI or other async frameworks
- Do not commit transactions manually when using context managers for sessions
- Do not skip indexes on foreign key columns as this causes N+1 query problems