Return an instance based on the given primary key identifier, or ``None`` if not found. .. seealso:: :meth:`_orm.Session.get` - main documentation for get
(
self,
entity: _EntityBindKey[_O],
ident: _PKIdentityArgument,
*,
options: Optional[Sequence[ORMOption]] = None,
populate_existing: bool | None = None,
with_for_update: ForUpdateParameter = None,
identity_token: Optional[Any] = None,
execution_options: OrmExecuteOptionsParameter = util.EMPTY_DICT,
)
| 587 | return result.scalars() |
| 588 | |
| 589 | async def get( |
| 590 | self, |
| 591 | entity: _EntityBindKey[_O], |
| 592 | ident: _PKIdentityArgument, |
| 593 | *, |
| 594 | options: Optional[Sequence[ORMOption]] = None, |
| 595 | populate_existing: bool | None = None, |
| 596 | with_for_update: ForUpdateParameter = None, |
| 597 | identity_token: Optional[Any] = None, |
| 598 | execution_options: OrmExecuteOptionsParameter = util.EMPTY_DICT, |
| 599 | ) -> Union[_O, None]: |
| 600 | """Return an instance based on the given primary key identifier, |
| 601 | or ``None`` if not found. |
| 602 | |
| 603 | .. seealso:: |
| 604 | |
| 605 | :meth:`_orm.Session.get` - main documentation for get |
| 606 | |
| 607 | |
| 608 | """ |
| 609 | |
| 610 | return await greenlet_spawn( |
| 611 | cast("Callable[..., _O]", self.sync_session.get), |
| 612 | entity, |
| 613 | ident, |
| 614 | options=options, |
| 615 | populate_existing=populate_existing, |
| 616 | with_for_update=with_for_update, |
| 617 | identity_token=identity_token, |
| 618 | execution_options=execution_options, |
| 619 | ) |
| 620 | |
| 621 | async def get_one( |
| 622 | self, |