r"""Construct a new :class:`_orm.Session`. See also the :class:`.sessionmaker` function which is used to generate a :class:`.Session`-producing callable with a given set of arguments. :param autoflush: When ``True``, all query operations will issue a :met
(
self,
bind: Optional[_SessionBind] = None,
*,
autoflush: bool = True,
future: Literal[True] = True,
expire_on_commit: bool = True,
autobegin: bool = True,
twophase: bool = False,
binds: Optional[Dict[_SessionBindKey, _SessionBind]] = None,
enable_baked_queries: bool = True,
info: Optional[_InfoType] = None,
query_cls: Optional[Type[Query[Any]]] = None,
autocommit: Literal[False] = False,
join_transaction_mode: JoinTransactionMode = "conditional_savepoint",
close_resets_only: Union[bool, _NoArg] = _NoArg.NO_ARG,
execution_options: OrmExecuteOptionsParameter = util.EMPTY_DICT,
)
| 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, |
| 1529 | info: Optional[_InfoType] = None, |
| 1530 | query_cls: Optional[Type[Query[Any]]] = None, |
| 1531 | autocommit: Literal[False] = False, |
| 1532 | join_transaction_mode: JoinTransactionMode = "conditional_savepoint", |
| 1533 | close_resets_only: Union[bool, _NoArg] = _NoArg.NO_ARG, |
| 1534 | execution_options: OrmExecuteOptionsParameter = util.EMPTY_DICT, |
| 1535 | ): |
| 1536 | r"""Construct a new :class:`_orm.Session`. |
| 1537 | |
| 1538 | See also the :class:`.sessionmaker` function which is used to |
| 1539 | generate a :class:`.Session`-producing callable with a given |
| 1540 | set of arguments. |
| 1541 | |
| 1542 | :param autoflush: When ``True``, all query operations will issue a |
| 1543 | :meth:`~.Session.flush` call to this ``Session`` before proceeding. |
| 1544 | This is a convenience feature so that :meth:`~.Session.flush` need |
| 1545 | not be called repeatedly in order for database queries to retrieve |
| 1546 | results. |
| 1547 | |
| 1548 | .. seealso:: |
| 1549 | |
| 1550 | :ref:`session_flushing` - additional background on autoflush |
| 1551 | |
| 1552 | :param autobegin: Automatically start transactions (i.e. equivalent to |
| 1553 | invoking :meth:`_orm.Session.begin`) when database access is |
| 1554 | requested by an operation. Defaults to ``True``. Set to |
| 1555 | ``False`` to prevent a :class:`_orm.Session` from implicitly |
| 1556 | beginning transactions after construction, as well as after any of |
| 1557 | the :meth:`_orm.Session.rollback`, :meth:`_orm.Session.commit`, |
| 1558 | or :meth:`_orm.Session.close` methods are called. |
| 1559 | |
| 1560 | .. versionadded:: 2.0 |
| 1561 | |
| 1562 | .. seealso:: |
| 1563 | |
| 1564 | :ref:`session_autobegin_disable` |
| 1565 | |
| 1566 | :param bind: An optional :class:`_engine.Engine` or |
| 1567 | :class:`_engine.Connection` to |
| 1568 | which this ``Session`` should be bound. When specified, all SQL |
| 1569 | operations performed by this session will execute via this |
| 1570 | connectable. |
| 1571 | |
| 1572 | :param binds: A dictionary which may specify any number of |
| 1573 | :class:`_engine.Engine` or :class:`_engine.Connection` |
| 1574 | objects as the source of |
| 1575 | connectivity for SQL operations on a per-entity basis. The keys |