File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -77,6 +77,11 @@ export default sidebar({
77
77
"opentelemetry" ,
78
78
] ,
79
79
} ,
80
+ {
81
+ text : "External connection pools" ,
82
+ prefix : "/extra_conn_pools" ,
83
+ link : "/external_connection_pools.md"
84
+ } ,
80
85
{
81
86
text : "Contribution guide" ,
82
87
prefix : "/contribution_guide" ,
Original file line number Diff line number Diff line change
1
+ ---
2
+ title : External connection pools
3
+ ---
4
+
5
+ PSQLPy supports external connection pools like [ PgBouncer] ( https://www.pgbouncer.org/ ) or [ Supavisor] ( https://github.com/supabase/supavisor ) .
6
+
7
+ Usually, external connection pools have 3 main [ modes] ( https://www.pgbouncer.org/features.html ) : ` Session ` , ` Transaction ` and ` Statement ` .
8
+
9
+ If you use ` Session ` mode, there is nothing you have to do, just use PSQLPy as usual.
10
+
11
+ But there are a few conditions that must be met to make ` Transaction ` and ` Statement ` work.
12
+
13
+ ### Disable statement preparation
14
+ Disable statement preparation for any sql statement execution (if a method has ` prepared ` parameter, set it to ` False ` ).
15
+
16
+ ### Execute statement only in transaction
17
+ Each statement must be executed in a transaction.
18
+
19
+ ``` python
20
+ db_pool = ConnectionPool(... )
21
+
22
+ async with db_pool.acquire() as conn:
23
+ async with conn.transaction() as transaction:
24
+ await transaction.execute(" SELECT 1" , prepared = False )
25
+ ```
You can’t perform that action at this time.
0 commit comments