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`.
| 1469 | |
| 1470 | |
| 1471 | class Session(_SessionClassMethods, EventTarget): |
| 1472 | class="st">"""Manages persistence operations for ORM-mapped objects. |
| 1473 | |
| 1474 | The :class:`_orm.Session` is **not safe for use in concurrent threads.**. |
| 1475 | See :ref:`session_faq_threadsafe` for background. |
| 1476 | |
| 1477 | The Session&class="cm">#x27;s usage paradigm is described at :doc:`/orm/session`. |
| 1478 | |
| 1479 | |
| 1480 | class="st">""" |
| 1481 | |
| 1482 | _is_asyncio = False |
| 1483 | |
| 1484 | dispatch: dispatcher[Session] |
| 1485 | |
| 1486 | identity_map: IdentityMap |
| 1487 | class="st">"""A mapping of object identities to objects themselves. |
| 1488 | |
| 1489 | Iterating through ``Session.identity_map.values()`` provides |
| 1490 | access to the full set of persistent objects (i.e., those |
| 1491 | that have row identity) currently in the session. |
| 1492 | |
| 1493 | .. seealso:: |
| 1494 | |
| 1495 | :func:`.identity_key` - helper function to produce the keys used |
| 1496 | in this dictionary. |
| 1497 | |
| 1498 | class="st">""" |
| 1499 | |
| 1500 | _new: Dict[InstanceState[Any], Any] |
| 1501 | _deleted: Dict[InstanceState[Any], Any] |
| 1502 | bind: Optional[Union[Engine, Connection]] |
| 1503 | __binds: Dict[_SessionBindKey, _SessionBind] |
| 1504 | _flushing: bool |
| 1505 | _warn_on_events: bool |
| 1506 | _transaction: Optional[SessionTransaction] |
| 1507 | _nested_transaction: Optional[SessionTransaction] |
| 1508 | hash_key: int |
| 1509 | autoflush: bool |
| 1510 | expire_on_commit: bool |
| 1511 | enable_baked_queries: bool |
| 1512 | twophase: bool |
| 1513 | join_transaction_mode: JoinTransactionMode |
| 1514 | execution_options: _ExecuteOptions = util.EMPTY_DICT |
| 1515 | _query_cls: Type[Query[Any]] |
| 1516 | _close_state: _SessionCloseState |
| 1517 | |
| 1518 | def __init__( |
| 1519 | self, |
| 1520 | bind: Optional[_SessionBind] = None, |
| 1521 | *, |
| 1522 | autoflush: bool = True, |
| 1523 | future: Literal[True] = True, |
| 1524 | expire_on_commit: bool = True, |
| 1525 | autobegin: bool = True, |
| 1526 | twophase: bool = False, |
| 1527 | binds: Optional[Dict[_SessionBindKey, _SessionBind]] = None, |
| 1528 | enable_baked_queries: bool = True, |
no outgoing calls