Skip to content

Commit 68eff10

Browse files
committed
Small fixes in README
1 parent 24709de commit 68eff10

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

README.md

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Create new instance of PSQLPool, startup it and start querying.
3333
```python
3434
from typing import Any
3535

36-
from psqlpy import PSQLPool
36+
from psqlpy import PSQLPool, QueryResult
3737

3838

3939
db_pool = PSQLPool(
@@ -48,11 +48,11 @@ db_pool = PSQLPool(
4848
async def main() -> None:
4949
await db_pool.startup()
5050

51-
res: list[dict[str, Any]] = await db_pool.execute(
51+
res: QueryResult = await db_pool.execute(
5252
"SELECT * FROM users",
5353
)
5454

55-
print(res)
55+
print(res.result())
5656
# You don't need to close Database Pool by yourself,
5757
# rust does it instead.
5858

@@ -65,7 +65,7 @@ You can separate specify `host`, `port`, `username`, etc or specify everything i
6565
```py
6666
from typing import Any
6767

68-
from psqlpy import PSQLPool
68+
from psqlpy import PSQLPool, QueryResult
6969

7070

7171
db_pool = PSQLPool(
@@ -76,11 +76,11 @@ db_pool = PSQLPool(
7676
async def main() -> None:
7777
await db_pool.startup()
7878

79-
res: list[dict[str, Any]] = await db_pool.execute(
79+
res: QueryResult = await db_pool.execute(
8080
"SELECT * FROM users",
8181
)
8282

83-
print(res)
83+
print(res.result())
8484
# You don't need to close Database Pool by yourself,
8585
# rust does it instead.
8686
```
@@ -127,7 +127,7 @@ You can work with connection instead of DatabasePool.
127127
```python
128128
from typing import Any
129129
130-
from psqlpy import PSQLPool
130+
from psqlpy import PSQLPool, QueryResult
131131
132132
133133
db_pool = PSQLPool(
@@ -144,11 +144,11 @@ async def main() -> None:
144144
145145
connection = await db_pool.connection()
146146
147-
res: list[dict[str, Any]] = await connection.execute(
147+
res: QueryResult = await connection.execute(
148148
"SELECT * FROM users",
149149
)
150150
151-
print(res)
151+
print(res.result())
152152
# You don't need to close connection by yourself,
153153
# rust does it instead.
154154
```
@@ -168,7 +168,7 @@ By default async context manager only begins and commits transaction automatical
168168
```python
169169
from typing import Any
170170

171-
from psqlpy import PSQLPool, IsolationLevel
171+
from psqlpy import PSQLPool, IsolationLevel, QueryResult
172172

173173

174174
db_pool = PSQLPool()
@@ -178,11 +178,11 @@ async def main() -> None:
178178

179179
connection = await db_pool.connection()
180180
async with connection.transaction() as transaction:
181-
res: list[dict[str, Any]] = await transaction.execute(
181+
res: QueryResult = await transaction.execute(
182182
"SELECT * FROM users",
183183
)
184184

185-
print(res)
185+
print(res.result())
186186
# You don't need to close Database Pool by yourself,
187187
# rust does it instead.
188188
```
@@ -212,8 +212,6 @@ async def main() -> None:
212212
# You must commit the transaction by your own
213213
# or your changes will be vanished.
214214
await transaction.commit()
215-
216-
print(res)
217215
# You don't need to close Database Pool by yourself,
218216
# rust does it instead.
219217
```
@@ -322,7 +320,7 @@ In process of cursor creation you can specify some configuration parameters.
322320
```python
323321
from typing import Any
324322

325-
from psqlpy import PSQLPool, IsolationLevel
323+
from psqlpy import PSQLPool, IsolationLevel, QueryResult
326324

327325

328326
db_pool = PSQLPool()
@@ -344,7 +342,7 @@ async def main() -> None:
344342
)
345343

346344
# You can manually fetch results from cursor
347-
results: list[dict[str, Any]] = await cursor.fetch(fetch_number=8)
345+
results: QueryResult = await cursor.fetch(fetch_number=8)
348346

349347
# Or you can use it as an async iterator.
350348
async for fetched_result in cursor:

0 commit comments

Comments
 (0)