@@ -16,13 +16,13 @@ different options for each.
1616## Session Management
1717
1818Most use cases will use one session, and tie it to the lifetime of each request.
19- Use {attr}` db.session <SQLAlchemy.session> ` for this. It will return the same
19+ Use {attr}` db.session <. SQLAlchemy.session> ` for this. It will return the same
2020session throughout a request, then close it when the request ends. SQLAlchemy
2121will rollback any uncomitted state in the session when it is closed.
2222
2323You can also create other sessions besides the default. Calling
24- {meth}` db.get_session(name) ` will create separate sessions that are also closed
25- at the end of the request.
24+ {meth}` db.get_session(name) <.SQLAlchemy.get_session> ` will create separate
25+ sessions that are also closed at the end of the request.
2626
2727The sessions are closed when the application context is torn down. This happens
2828for each request, but also at the end of CLI commands, and for manual
@@ -31,7 +31,7 @@ for each request, but also at the end of CLI commands, and for manual
3131
3232### Manual Sessions
3333
34- You can also use {attr}` db.sessionmaker <SQLAlchemy.sessionmaker> ` directly to
34+ You can also use {attr}` db.sessionmaker <. SQLAlchemy.sessionmaker> ` directly to
3535create sessions. These will not be closed automatically at the end of requests,
3636so you'll need to manage them manually. An easy way to do that is using a ` with `
3737block.
@@ -47,9 +47,10 @@ with db.sessionmaker() as session:
4747SQLAlchemy warns that the async sessions it provides are _ not_ safe to be used
4848across concurrent tasks. For example, the same session should not be passed to
4949multiple tasks when using ` asyncio.gather ` . Either use
50- {meth}` db.get_async_session(name) <SQLAlchemy.get_async_session> ` with a unique
51- name for each task, or use {attr}` db.async_sessionmaker ` to manage sessions
52- and their lifetime manually. The latter is what SQLAlchemy recommends.
50+ {meth}` db.get_async_session(name) <.SQLAlchemy.get_async_session> ` with a unique
51+ name for each task, or use
52+ {attr}` db.async_sessionmaker <.SQLAlchemy.async_sessionmaker> ` to manage session
53+ lifetimes manually. The latter is what SQLAlchemy recommends.
5354
5455
5556## Multiple Binds
0 commit comments