Given an object, return the primary Mapper associated with the object instance. Raises :class:`sqlalchemy.orm.exc.UnmappedInstanceError` if no mapping is configured. This function is available via the inspection system as:: inspect(instance).mapper Using the inspectio
(instance: _T)
| 386 | |
| 387 | |
| 388 | def object_mapper(instance: _T) -> Mapper[_T]: |
| 389 | """Given an object, return the primary Mapper associated with the object |
| 390 | instance. |
| 391 | |
| 392 | Raises :class:`sqlalchemy.orm.exc.UnmappedInstanceError` |
| 393 | if no mapping is configured. |
| 394 | |
| 395 | This function is available via the inspection system as:: |
| 396 | |
| 397 | inspect(instance).mapper |
| 398 | |
| 399 | Using the inspection system will raise |
| 400 | :class:`sqlalchemy.exc.NoInspectionAvailable` if the instance is |
| 401 | not part of a mapping. |
| 402 | |
| 403 | """ |
| 404 | return object_state(instance).mapper |
| 405 | |
| 406 | |
| 407 | def object_state(instance: _T) -> InstanceState[_T]: |