sqlmodel-crud
创建 SQLModel 数据库模型与 CRUD 操作
创建 SQLModel 数据库模型需要理解 Pydantic 集成、异步会话以及关系配置。本技能提供专家级模式,用于构建类型安全的数据库操作并进行正确的校验。
Baixar o ZIP da skill
Upload no Claude
Vá em Configurações → Capacidades → Skills → Upload skill
Ative e comece a usar
Testar
A utilizar "sqlmodel-crud". Create a Student model with name, email, and enrollment date fields
Resultado esperado:
- 创建 Student 模型,包含 id(UUID 主键)、name(2-100 字符必填)、email(唯一索引)、enrollment_date(datetime)以及时间戳
- 添加 table=True 用于创建数据库表
- 配置可选的 is_active 字段,默认 True
- 可直接用于 CRUD 操作
A utilizar "sqlmodel-crud". Build a query to find all students with pending fees in a class
Resultado esperado:
- 编写子查询以查找费用状态为待处理的学生
- 使用 join 连接 Student 表并按 class_id 过滤
- 添加 offset 与 limit 分页
- 按学生姓名字母顺序排序结果
Auditoria de Segurança
SeguroPure documentation skill containing guidance examples for SQLModel database operations. No executable code, no network calls, no filesystem access beyond reading the skill file itself. All static findings are false positives from the scanner misinterpreting markdown code blocks as shell commands and field names as cryptographic patterns.
Fatores de risco
🌐 Acesso à rede (6)
📁 Acesso ao sistema de arquivos (1)
⚙️ Comandos externos (65)
🔑 Variáveis de ambiente (5)
Pontuação de qualidade
O Que Você Pode Construir
构建类型安全的 FastAPI 端点
为 FastAPI 路由创建 SQLModel 模型与 CRUD 操作,并进行合适的 Pydantic 校验与异步数据库会话管理。
设计数据库架构
设计包含一对多、多对多与一对一模式的实体关系,并配置正确的外键。
编写复杂查询
为报表系统构建包含 join、子查询、聚合、条件逻辑与分页的高级查询。
Tente Estes Prompts
Create a SQLModel table=True model called Product with id, name, price, and description fields including proper validation constraints.
Write async CRUD operations for a Product model including create, get_by_id, get_all with pagination, update, and delete methods using AsyncSession.
Create SQLModel models for Order and OrderItem with one-to-many relationship including back_populates and proper foreign key configuration.
Write a query to get orders with their items using eager loading with selectinload, filtering by date range, and ordering by created_at descending.
Melhores Práticas
- 对所有数据库模型使用 table=True,并为请求/响应 schema 分离 Pydantic 模型
- 在高频过滤字段上添加 index=True,在 email 与其他业务键上添加 unique=True
- 异步应用始终使用 AsyncSession,并通过 commit/rollback 处理事务
Evitar
- 不要在不了解批量赋值安全影响的情况下使用 from_attributes = True
- 避免在同一个类定义中混用 SQLModel 与 Pydantic 模型而没有正确分离
- 不要跳过 created_at 与 updated_at 时间戳的添加,否则缺少审计追踪
Perguntas Frequentes
支持哪些 Python 版本?
SQLModel 支持哪些数据库?
如何与 FastAPI 集成?
使用该技能我的数据安全吗?
为什么我的查询很慢?
这与 SQLAlchemy 相比如何?
Detalhes do Desenvolvedor
Autor
Awais68Licença
MIT
Repositório
https://github.com/Awais68/hackathon-2-phase-ii-full-stack-web-app/tree/main/.claude/skills/sqlmodel-crudReferência
main
Estrutura de arquivos
📄 SKILL.md