r"""Create a new :class:`.Session` with no automation enabled by default. This function is used primarily for testing. The usual route to :class:`.Session` creation is via its constructor or the :func:`.sessionmaker` function. :param bind: optional, a single Connectable to us
(
bind: Optional[_SessionBind] = None, **kwargs: Any
)
| 2079 | |
| 2080 | |
| 2081 | def create_session( |
| 2082 | bind: Optional[_SessionBind] = None, **kwargs: Any |
| 2083 | ) -> Session: |
| 2084 | r"""Create a new :class:`.Session` |
| 2085 | with no automation enabled by default. |
| 2086 | |
| 2087 | This function is used primarily for testing. The usual |
| 2088 | route to :class:`.Session` creation is via its constructor |
| 2089 | or the :func:`.sessionmaker` function. |
| 2090 | |
| 2091 | :param bind: optional, a single Connectable to use for all |
| 2092 | database access in the created |
| 2093 | :class:`~sqlalchemy.orm.session.Session`. |
| 2094 | |
| 2095 | :param \*\*kwargs: optional, passed through to the |
| 2096 | :class:`.Session` constructor. |
| 2097 | |
| 2098 | :returns: an :class:`~sqlalchemy.orm.session.Session` instance |
| 2099 | |
| 2100 | The defaults of create_session() are the opposite of that of |
| 2101 | :func:`sessionmaker`; ``autoflush`` and ``expire_on_commit`` are |
| 2102 | False. |
| 2103 | |
| 2104 | Usage:: |
| 2105 | |
| 2106 | >>> from sqlalchemy.orm import create_session |
| 2107 | >>> session = create_session() |
| 2108 | |
| 2109 | It is recommended to use :func:`sessionmaker` instead of |
| 2110 | create_session(). |
| 2111 | |
| 2112 | """ |
| 2113 | |
| 2114 | kwargs.setdefault("autoflush", False) |
| 2115 | kwargs.setdefault("expire_on_commit", False) |
| 2116 | return Session(bind=bind, **kwargs) |
| 2117 | |
| 2118 | |
| 2119 | def _mapper_fn(*arg: Any, **kw: Any) -> NoReturn: |
nothing calls this directly
no test coverage detected