完成项目训练模块的接口测试
This commit is contained in:
10
core/crud.py
10
core/crud.py
@ -263,11 +263,17 @@ class DalBase:
|
||||
await self.db.execute(insert(self.model), datas)
|
||||
await self.db.flush()
|
||||
|
||||
async def create_model(self, data: Any) -> None:
|
||||
"""
|
||||
创建单个model
|
||||
:param data: model
|
||||
"""
|
||||
self.db.add(data)
|
||||
await self.db.flush()
|
||||
|
||||
async def create_models(self, datas: list[Any]) -> None:
|
||||
"""
|
||||
批量创建数据
|
||||
SQLAlchemy 2.0 批量插入不支持 MySQL 返回值:
|
||||
https://docs.sqlalchemy.org/en/20/orm/queryguide/dml.html#getting-new-objects-with-returning
|
||||
:param datas: model数组
|
||||
"""
|
||||
self.db.add_all(datas)
|
||||
|
Reference in New Issue
Block a user