Skip to content

Commit

Permalink
fix api links
Browse files Browse the repository at this point in the history
  • Loading branch information
davidism committed Jun 8, 2024
1 parent 36abb96 commit 013ddd6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
6 changes: 3 additions & 3 deletions docs/engine.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ The connection charset is set to `utf8mb4`.

## The Default Engine and Bind

The `"default"` key is special, and will be used for {attr}`.SQLAlchemy.engine`
and as the default bind for {attr}`.SQLAlchemy.sessionmaker`. By default, it is
The `"default"` key is special, and will be used for {attr}`~.SQLAlchemy.engine`
and as the default bind for {attr}`~.SQLAlchemy.sessionmaker`. By default, it is
an error not to configure it for one of sync or async engines.


Expand All @@ -107,7 +107,7 @@ an error not to configure it for one of sync or async engines.
You can ignore the Flask config altogether and create engines yourself. In that
case, you pass `require_default_engine=False` when creating the extension to
ignore the check for default config. Adding custom engines to the
{attr}`.SQLAlchemy.engines` map will make them accessible through the extension,
{attr}`~.SQLAlchemy.engines` map will make them accessible through the extension,
but that's not required either. You will want to call
`db.sessionmaker.configure(bind=..., binds=...)` to set up these custom engines
if you plan to use the provided session management though.
15 changes: 8 additions & 7 deletions docs/session.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ different options for each.
## Session Management

Most use cases will use one session, and tie it to the lifetime of each request.
Use {attr}`db.session <SQLAlchemy.session>` for this. It will return the same
Use {attr}`db.session <.SQLAlchemy.session>` for this. It will return the same
session throughout a request, then close it when the request ends. SQLAlchemy
will rollback any uncomitted state in the session when it is closed.

You can also create other sessions besides the default. Calling
{meth}`db.get_session(name)` will create separate sessions that are also closed
at the end of the request.
{meth}`db.get_session(name) <.SQLAlchemy.get_session>` will create separate
sessions that are also closed at the end of the request.

The sessions are closed when the application context is torn down. This happens
for each request, but also at the end of CLI commands, and for manual
Expand All @@ -31,7 +31,7 @@ for each request, but also at the end of CLI commands, and for manual

### Manual Sessions

You can also use {attr}`db.sessionmaker <SQLAlchemy.sessionmaker>` directly to
You can also use {attr}`db.sessionmaker <.SQLAlchemy.sessionmaker>` directly to
create sessions. These will not be closed automatically at the end of requests,
so you'll need to manage them manually. An easy way to do that is using a `with`
block.
Expand All @@ -47,9 +47,10 @@ with db.sessionmaker() as session:
SQLAlchemy warns that the async sessions it provides are _not_ safe to be used
across concurrent tasks. For example, the same session should not be passed to
multiple tasks when using `asyncio.gather`. Either use
{meth}`db.get_async_session(name) <SQLAlchemy.get_async_session>` with a unique
name for each task, or use {attr}`db.async_sessionmaker` to manage sessions
and their lifetime manually. The latter is what SQLAlchemy recommends.
{meth}`db.get_async_session(name) <.SQLAlchemy.get_async_session>` with a unique
name for each task, or use
{attr}`db.async_sessionmaker <.SQLAlchemy.async_sessionmaker>` to manage session
lifetimes manually. The latter is what SQLAlchemy recommends.


## Multiple Binds
Expand Down
9 changes: 5 additions & 4 deletions docs/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ SQLAlchemy.
Create an instance of {class}`.SQLAlchemy`. Define the
{data}`.SQLALCHEMY_ENGINES` config, a dict, with at least the `"default"` key
with a [connection string] value. When setting up the Flask app, call the
extension's {meth}`.SQLAlchemy.init_app` method.
extension's {meth}`~.SQLAlchemy.init_app` method.

[connection string]: https://docs.sqlalchemy.org/core/engines.html#database-urls

Expand Down Expand Up @@ -200,6 +200,7 @@ be aware of than with sync usage.
In particular, SQLAlchemy warns that the async sessions it provides are _not_
safe to be used across concurrent tasks. For example, the same session should
not be passed to multiple tasks when using `asyncio.gather`. Either use
{meth}`db.get_async_session(name) <SQLAlchemy.get_async_session>` with a unique
name for each task, or use {attr}`db.async_sessionmaker` to manage sessions
and their lifetime manually. The latter is what SQLAlchemy recommends.
{meth}`db.get_async_session(name) <.SQLAlchemy.get_async_session>` with a unique
name for each task, or use
{attr}`db.async_sessionmaker <.SQLAlchemy.async_sessionmaker>` to manage session
lifetimes manually. The latter is what SQLAlchemy recommends.

0 comments on commit 013ddd6

Please sign in to comment.