You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+7-28Lines changed: 7 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -109,8 +109,6 @@ db_pool = PSQLPool(
109
109
)
110
110
111
111
asyncdefmain() -> None:
112
-
await db_pool.startup()
113
-
114
112
res: QueryResult =await db_pool.execute(
115
113
"SELECT * FROM users",
116
114
)
@@ -147,10 +145,12 @@ As connection can be closed in different situations on various sides you can sel
147
145
rendered ineffective.
148
146
149
147
## Results from querying
148
+
150
149
You have some options to get results from the query.
151
150
`execute()` method, for example, returns `QueryResult` and this class can be converted into `list` of `dict`s - `list[dict[Any, Any]]` or into any Python class (`pydantic` model, as an example).
152
151
153
152
Let's see some code:
153
+
154
154
```python
155
155
from typing import Any
156
156
@@ -169,8 +169,6 @@ db_pool = PSQLPool(
169
169
)
170
170
171
171
asyncdefmain() -> None:
172
-
await db_pool.startup()
173
-
174
172
res: QueryResult =await db_pool.execute(
175
173
"SELECT * FROM users",
176
174
)
@@ -213,8 +211,6 @@ db_pool = PSQLPool(
213
211
)
214
212
215
213
asyncdefmain() -> None:
216
-
await db_pool.startup()
217
-
218
214
connection =await db_pool.connection()
219
215
220
216
res: QueryResult =await connection.execute(
@@ -252,8 +248,6 @@ from psqlpy import PSQLPool, IsolationLevel, QueryResult
252
248
db_pool = PSQLPool()
253
249
254
250
asyncdefmain() -> None:
255
-
await db_pool.startup()
256
-
257
251
connection =await db_pool.connection()
258
252
asyncwith connection.transaction() as transaction:
259
253
res: QueryResult =await transaction.execute(
@@ -276,8 +270,6 @@ from psqlpy import PSQLPool, IsolationLevel
276
270
db_pool = PSQLPool()
277
271
278
272
asyncdefmain() -> None:
279
-
await db_pool.startup()
280
-
281
273
connection =await db_pool.connection()
282
274
transaction = connection.transaction(
283
275
isolation_level=IsolationLevel.Serializable,
@@ -310,8 +302,6 @@ from psqlpy import PSQLPool, IsolationLevel
310
302
db_pool = PSQLPool()
311
303
312
304
asyncdefmain() -> None:
313
-
await db_pool.startup()
314
-
315
305
connection =await db_pool.connection()
316
306
transaction = connection.transaction(
317
307
isolation_level=IsolationLevel.Serializable,
@@ -339,8 +329,6 @@ from psqlpy import PSQLPool, IsolationLevel
339
329
db_pool = PSQLPool()
340
330
341
331
asyncdefmain() -> None:
342
-
await db_pool.startup()
343
-
344
332
connection =await db_pool.connection()
345
333
transaction = connection.transaction(
346
334
isolation_level=IsolationLevel.Serializable,
@@ -367,8 +355,6 @@ from psqlpy import PSQLPool, IsolationLevel
367
355
db_pool = PSQLPool()
368
356
369
357
asyncdefmain() -> None:
370
-
await db_pool.startup()
371
-
372
358
connection =await db_pool.connection()
373
359
transaction = connection.transaction(
374
360
isolation_level=IsolationLevel.Serializable,
@@ -383,13 +369,15 @@ async def main() -> None:
383
369
```
384
370
385
371
### Transaction pipelining
372
+
386
373
When you have a lot of independent queries and want to execute them concurrently, you can use `pipeline`.
387
374
Pipelining can improve performance in use cases in which multiple,
388
375
independent queries need to be executed.
389
376
In a traditional workflow,
390
377
each query is sent to the server after the previous query completes.
391
378
In contrast, pipelining allows the client to send all of the queries to the server up front,
392
379
minimizing time spent by one side waiting for the other to finish sending data:
380
+
393
381
```
394
382
Sequential Pipelined
395
383
| Client | Server | | Client | Server |
@@ -404,9 +392,11 @@ minimizing time spent by one side waiting for the other to finish sending data:
0 commit comments