@@ -33,7 +33,7 @@ Create new instance of PSQLPool, startup it and start querying.
33
33
``` python
34
34
from typing import Any
35
35
36
- from psqlpy import PSQLPool
36
+ from psqlpy import PSQLPool, QueryResult
37
37
38
38
39
39
db_pool = PSQLPool(
@@ -48,11 +48,11 @@ db_pool = PSQLPool(
48
48
async def main () -> None :
49
49
await db_pool.startup()
50
50
51
- res: list[dict[ str , Any]] = await db_pool.execute(
51
+ res: QueryResult = await db_pool.execute(
52
52
" SELECT * FROM users" ,
53
53
)
54
54
55
- print (res)
55
+ print (res.result() )
56
56
# You don't need to close Database Pool by yourself,
57
57
# rust does it instead.
58
58
@@ -65,7 +65,7 @@ You can separate specify `host`, `port`, `username`, etc or specify everything i
65
65
``` py
66
66
from typing import Any
67
67
68
- from psqlpy import PSQLPool
68
+ from psqlpy import PSQLPool, QueryResult
69
69
70
70
71
71
db_pool = PSQLPool(
@@ -76,11 +76,11 @@ db_pool = PSQLPool(
76
76
async def main () -> None :
77
77
await db_pool.startup()
78
78
79
- res: list[dict[ str , Any]] = await db_pool.execute(
79
+ res: QueryResult = await db_pool.execute(
80
80
" SELECT * FROM users" ,
81
81
)
82
82
83
- print (res)
83
+ print (res.result() )
84
84
# You don't need to close Database Pool by yourself,
85
85
# rust does it instead.
86
86
```
@@ -127,7 +127,7 @@ You can work with connection instead of DatabasePool.
127
127
```python
128
128
from typing import Any
129
129
130
- from psqlpy import PSQLPool
130
+ from psqlpy import PSQLPool, QueryResult
131
131
132
132
133
133
db_pool = PSQLPool(
@@ -144,11 +144,11 @@ async def main() -> None:
144
144
145
145
connection = await db_pool.connection()
146
146
147
- res: list[dict[str, Any]] = await connection.execute(
147
+ res: QueryResult = await connection.execute(
148
148
"SELECT * FROM users",
149
149
)
150
150
151
- print(res)
151
+ print(res.result() )
152
152
# You don' t need to close connection by yourself,
153
153
# rust does it instead.
154
154
```
@@ -168,7 +168,7 @@ By default async context manager only begins and commits transaction automatical
168
168
``` python
169
169
from typing import Any
170
170
171
- from psqlpy import PSQLPool, IsolationLevel
171
+ from psqlpy import PSQLPool, IsolationLevel, QueryResult
172
172
173
173
174
174
db_pool = PSQLPool()
@@ -178,11 +178,11 @@ async def main() -> None:
178
178
179
179
connection = await db_pool.connection()
180
180
async with connection.transaction() as transaction:
181
- res: list[dict[ str , Any]] = await transaction.execute(
181
+ res: QueryResult = await transaction.execute(
182
182
" SELECT * FROM users" ,
183
183
)
184
184
185
- print (res)
185
+ print (res.result() )
186
186
# You don't need to close Database Pool by yourself,
187
187
# rust does it instead.
188
188
```
@@ -212,8 +212,6 @@ async def main() -> None:
212
212
# You must commit the transaction by your own
213
213
# or your changes will be vanished.
214
214
await transaction.commit()
215
-
216
- print (res)
217
215
# You don't need to close Database Pool by yourself,
218
216
# rust does it instead.
219
217
```
@@ -322,7 +320,7 @@ In process of cursor creation you can specify some configuration parameters.
322
320
``` python
323
321
from typing import Any
324
322
325
- from psqlpy import PSQLPool, IsolationLevel
323
+ from psqlpy import PSQLPool, IsolationLevel, QueryResult
326
324
327
325
328
326
db_pool = PSQLPool()
@@ -344,7 +342,7 @@ async def main() -> None:
344
342
)
345
343
346
344
# 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 )
348
346
349
347
# Or you can use it as an async iterator.
350
348
async for fetched_result in cursor:
0 commit comments