MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / __init__

Method __init__

lib/sqlalchemy/orm/session.py:1504–1803  ·  view source on GitHub ↗

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,
    )

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

_add_bindMethod · 0.95
updateMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected