• tortoise-orm官方
  • 异步 类方法 bulk_create(对象 batch_size None using_db None
  • 批量插入操作将尽量保证在 DB 中创建的对象具有所有默认值和生成的字段集,但在 Python 中可能是不完整的引用
    •  
      @cases.post("/test/", name="批量新增")
      async def create(case: List[models.CaseIn_Pydantic]):
          result = [models.Case(**c.dict(exclude_unset=True)) for c in case]
          try:
              await models.Case.bulk_create(result)  # bulk_create批量插入操作
              return core.Success(data=await models.Case.from_queryset(models.Case))
          except Exception as e:
              return core.Fail(message=f"创建失败.{e}")
       
    •   fastapi-tortoise-orm批量插入数据库

       

       

相关文章:

  • 2021-11-01
  • 2021-11-01
  • 2021-05-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-21
  • 2022-12-23
  • 2021-06-11
  • 2022-12-23
  • 2021-11-01
  • 2021-06-29
  • 2022-12-23
相关资源
相似解决方案