Insert rows into the database. .. code-block:: python await Band.insert( Band(name="Pythonistas", popularity=500, manager=1) )
(
cls: type[TableInstance], *rows: TableInstance
)
| 1059 | |
| 1060 | @classmethod |
| 1061 | def insert( |
| 1062 | cls: type[TableInstance], *rows: TableInstance |
| 1063 | ) -> Insert[TableInstance]: |
| 1064 | """ |
| 1065 | Insert rows into the database. |
| 1066 | |
| 1067 | .. code-block:: python |
| 1068 | |
| 1069 | await Band.insert( |
| 1070 | Band(name="Pythonistas", popularity=500, manager=1) |
| 1071 | ) |
| 1072 | |
| 1073 | """ |
| 1074 | query = Insert(table=cls).returning(cls._meta.primary_key) |
| 1075 | if rows: |
| 1076 | query.add(*rows) |
| 1077 | return query |
| 1078 | |
| 1079 | @classmethod |
| 1080 | def raw(cls, sql: str, *args: Any) -> Raw: |