Skip to content

Commit 9ed172a

Browse files
committed
sync changes from PR: #13 to md docs sources
1 parent b7060a6 commit 9ed172a

File tree

2 files changed

+20
-22
lines changed

2 files changed

+20
-22
lines changed

docs_sources/docs/getting_started.md

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Configure the connection to the database
44

5-
For example, for PostgreSQL - database.py:
5+
For example, for PostgreSQL's database.py:
66

77
```python
88
from sqlalchemy.ext.asyncio import (
@@ -52,16 +52,16 @@ connection = DBConnect(
5252
```
5353

5454
The **host** parameter is optional if you use a handler
55-
before creating a session - `before_create_session_handler`.
56-
In that case, you can dynamically set the host.
55+
before creating a session: `before_create_session_handler`.
56+
From there, you can dynamically set the host.
5757

5858
Read more in [Master/Replica or several databases at the same time](master_replica.md)
5959

6060

61-
## Manage Database connection lifecycle
61+
## Manage the database connection lifecycle
6262

6363

64-
Close resources at the end of your application's lifecycle.
64+
Close the resources at the end of your application's lifecycle.
6565

6666
Example for FastAPI:
6767

@@ -82,10 +82,10 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[None, Any]:
8282

8383
## Setup middleware
8484

85-
Middleware handles the most important and complex part -
85+
Middleware handles the most important and complex parts:
8686
managing context and sessions.
8787

88-
You can use the ready-made middleware components:
88+
You can use ready-made middleware components:
8989

9090
### Pure ASGI
9191

@@ -119,9 +119,8 @@ add_starlette_http_db_session_middleware(app)
119119

120120
### Write own
121121

122-
If there’s no ready-made solution that fits your needs - don’t worry!
123-
You can check out [how it works](how_middleware_works.md) and implement your
124-
own.
122+
If there’s no ready-made solution that fits your needs, don’t worry!
123+
You can check out [how it works](how_middleware_works.md) implement your own.
125124

126125

127126
## Use it
@@ -155,14 +154,13 @@ async def some_func() -> None:
155154

156155
## Examples
157156

158-
The repository includes an example integration with FastAPI, demonstrating
159-
various workflows:
160-
[FastAPI example](https://github.com/krylosov-aa/context-async-sqlalchemy/tree/main/examples/fastapi_example/routes)
157+
The repository includes an example integration with [FastAPI](https://github.com/krylosov-aa/context-async-sqlalchemy/tree/main/examples/fastapi_example/routes)
158+
demonstrating various workflows.
161159

162160
It also contains two types of test setups that you can use in your own
163161
projects.
164162

165163
All library tests are included within the examples - because we aim to
166-
test the functionality not in isolation, but in the context of a real
164+
test the functionality in the context of a real,
167165
asynchronous web application.
168166
[FastAPI tests example](https://github.com/krylosov-aa/context-async-sqlalchemy/tree/main/examples/fastapi_example/tests)

docs_sources/docs/problem.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
SQLAlchemy uses an engine that manages the connection pool.
44
The engine must remain active for as long as the application is
5-
running, so it can quickly provide ready-to-use connections whenever the
5+
running, providing ready-to-use connections whenever the
66
application needs them.
77

88
In the application, we work with sessions.
@@ -16,9 +16,9 @@ Let's see what existing solutions are available to manage sessions:
1616

1717
### Manual solution
1818

19-
This is how the code ends up being duplicated,
20-
and two connections and two transactions are used - even though
21-
in many cases only one connection and one transaction are actually needed.
19+
This is how the code duplicates,
20+
and two connections and two transactions are in use - even when only one
21+
connection and one transaction are actually needed.
2222

2323
```python
2424
@app.post("/users/")
@@ -60,7 +60,7 @@ async def insert_user_profile(name, session):
6060
await session.execute(stmt)
6161
```
6262

63-
But if you look at it more broadly, the code duplication doesn’t actually go
63+
If you look at it more broadly, the code duplication doesn’t go
6464
away - you still have to do this in every handler.
6565

6666

@@ -79,9 +79,9 @@ async def create_cat(name):
7979
...
8080
```
8181

82-
You also have to set everything up yourself.
83-
No ready-made integration solutions are used - which means freedom on one
84-
hand, but a lot of code on the other.
82+
You also have to set everything up manually.
83+
No ready-made integration solutions are available - which means freedom
84+
but also a lot of coding.
8585

8686
### Dependency
8787

0 commit comments

Comments
 (0)