MCPcopy
hub / github.com/tortoise/tortoise-orm / create

Method create

tortoise/models.py:1364–1388  ·  view source on GitHub ↗

Create a record in the DB and returns the object. .. code-block:: python3 user = await User.create(name="...", email="...") Equivalent to: .. code-block:: python3 user = User(name="...", email="...") await user.save()

(
        cls: type[MODEL], using_db: BaseDBAsyncClient | None = None, **kwargs: Any
    )

Source from the content-addressed store, hash-verified

1362
1363 @classmethod
1364 async def create(
1365 cls: type[MODEL], using_db: BaseDBAsyncClient | None = None, **kwargs: Any
1366 ) -> MODEL:
1367 """
1368 Create a record in the DB and returns the object.
1369
1370 .. code-block:: python3
1371
1372 user = await User.create(name="...", email="...")
1373
1374 Equivalent to:
1375
1376 .. code-block:: python3
1377
1378 user = User(name="...", email="...")
1379 await user.save()
1380
1381 :param using_db: Specific DB connection to use instead of default bound
1382 :param kwargs: Model parameters.
1383 """
1384 instance = cls(**kwargs)
1385 instance._saved_in_db = False
1386 db = using_db or cls._choose_db(True)
1387 await instance.save(using_db=db, force_create=True)
1388 return instance
1389
1390 @classmethod
1391 def bulk_update(

Calls 2

saveMethod · 0.80
_choose_dbMethod · 0.45