Manages persistence operations for ORM-mapped objects. The :class:`_orm.Session` is **not safe for use in concurrent threads.**. See :ref:`session_faq_threadsafe` for background. The Session's usage paradigm is described at :doc:`/orm/session`.
| 1456 | |
| 1457 | |
| 1458 | class Session(_SessionClassMethods, EventTarget): |
| 1459 | """Manages persistence operations for ORM-mapped objects. |
| 1460 | |
| 1461 | The :class:`_orm.Session` is **not safe for use in concurrent threads.**. |
| 1462 | See :ref:`session_faq_threadsafe` for background. |
| 1463 | |
| 1464 | The Session's usage paradigm is described at :doc:`/orm/session`. |
| 1465 | |
| 1466 | |
| 1467 | """ |
| 1468 | |
| 1469 | _is_asyncio = False |
| 1470 | |
| 1471 | dispatch: dispatcher[Session] |
| 1472 | |
| 1473 | identity_map: IdentityMap |
| 1474 | """A mapping of object identities to objects themselves. |
| 1475 | |
| 1476 | Iterating through ``Session.identity_map.values()`` provides |
| 1477 | access to the full set of persistent objects (i.e., those |
| 1478 | that have row identity) currently in the session. |
| 1479 | |
| 1480 | .. seealso:: |
| 1481 | |
| 1482 | :func:`.identity_key` - helper function to produce the keys used |
| 1483 | in this dictionary. |
| 1484 | |
| 1485 | """ |
| 1486 | |
| 1487 | _new: Dict[InstanceState[Any], Any] |
| 1488 | _deleted: Dict[InstanceState[Any], Any] |
| 1489 | bind: Optional[Union[Engine, Connection]] |
| 1490 | __binds: Dict[_SessionBindKey, _SessionBind] |
| 1491 | _flushing: bool |
| 1492 | _warn_on_events: bool |
| 1493 | _transaction: Optional[SessionTransaction] |
| 1494 | _nested_transaction: Optional[SessionTransaction] |
| 1495 | hash_key: int |
| 1496 | autoflush: bool |
| 1497 | expire_on_commit: bool |
| 1498 | enable_baked_queries: bool |
| 1499 | twophase: bool |
| 1500 | join_transaction_mode: JoinTransactionMode |
| 1501 | _query_cls: Type[Query[Any]] |
| 1502 | _close_state: _SessionCloseState |
| 1503 | |
| 1504 | def __init__( |
| 1505 | self, |
| 1506 | bind: Optional[_SessionBind] = None, |
| 1507 | *, |
| 1508 | autoflush: bool = True, |
| 1509 | future: Literal[True] = True, |
| 1510 | expire_on_commit: bool = True, |
| 1511 | autobegin: bool = True, |
| 1512 | twophase: bool = False, |
| 1513 | binds: Optional[Dict[_SessionBindKey, _SessionBind]] = None, |
| 1514 | enable_baked_queries: bool = True, |
| 1515 | info: Optional[_InfoType] = None, |
no outgoing calls