@@ -2,9 +2,9 @@ import types
2
2
from enum import Enum
3
3
from io import BytesIO
4
4
from ipaddress import IPv4Address , IPv6Address
5
- from typing import Any , Awaitable , Callable , Sequence , TypeVar
5
+ from typing import Any , Awaitable , Callable , Mapping , Sequence , TypeVar
6
6
7
- from typing_extensions import Buffer , Self
7
+ from typing_extensions import Buffer , Self , TypeAlias
8
8
9
9
_CustomClass = TypeVar (
10
10
"_CustomClass" ,
@@ -13,6 +13,8 @@ _RowFactoryRV = TypeVar(
13
13
"_RowFactoryRV" ,
14
14
)
15
15
16
+ ParamsT : TypeAlias = Sequence [Any ] | Mapping [str , Any ] | None
17
+
16
18
class QueryResult :
17
19
"""Result."""
18
20
@@ -150,7 +152,7 @@ class SingleQueryResult:
150
152
151
153
class SynchronousCommit (Enum ):
152
154
"""
153
- Class for synchronous_commit option for transactions.
155
+ Synchronous_commit option for transactions.
154
156
155
157
### Variants:
156
158
- `On`: The meaning may change based on whether you have
@@ -181,7 +183,7 @@ class SynchronousCommit(Enum):
181
183
RemoteApply = 5
182
184
183
185
class IsolationLevel (Enum ):
184
- """Class for Isolation Level for transactions."""
186
+ """Isolation Level for transactions."""
185
187
186
188
ReadUncommitted = 1
187
189
ReadCommitted = 2
@@ -290,7 +292,7 @@ class Cursor:
290
292
291
293
cursor_name : str
292
294
querystring : str
293
- parameters : Sequence [ Any ]
295
+ parameters : ParamsT = None
294
296
prepared : bool | None
295
297
conn_dbname : str | None
296
298
user : str | None
@@ -464,7 +466,7 @@ class Transaction:
464
466
async def execute (
465
467
self : Self ,
466
468
querystring : str ,
467
- parameters : Sequence [ Any ] | None = None ,
469
+ parameters : ParamsT = None ,
468
470
prepared : bool = True ,
469
471
) -> QueryResult :
470
472
"""Execute the query.
@@ -554,7 +556,7 @@ class Transaction:
554
556
async def fetch (
555
557
self : Self ,
556
558
querystring : str ,
557
- parameters : Sequence [ Any ] | None = None ,
559
+ parameters : ParamsT = None ,
558
560
prepared : bool = True ,
559
561
) -> QueryResult :
560
562
"""Fetch the result from database.
@@ -574,7 +576,7 @@ class Transaction:
574
576
async def fetch_row (
575
577
self : Self ,
576
578
querystring : str ,
577
- parameters : Sequence [ Any ] | None = None ,
579
+ parameters : ParamsT = None ,
578
580
prepared : bool = True ,
579
581
) -> SingleQueryResult :
580
582
"""Fetch exaclty single row from query.
@@ -613,7 +615,7 @@ class Transaction:
613
615
async def fetch_val (
614
616
self : Self ,
615
617
querystring : str ,
616
- parameters : Sequence [ Any ] | None = None ,
618
+ parameters : ParamsT = None ,
617
619
prepared : bool = True ,
618
620
) -> Any | None :
619
621
"""Execute the query and return first value of the first row.
@@ -814,7 +816,7 @@ class Transaction:
814
816
def cursor (
815
817
self : Self ,
816
818
querystring : str ,
817
- parameters : Sequence [ Any ] | None = None ,
819
+ parameters : ParamsT = None ,
818
820
fetch_number : int | None = None ,
819
821
scroll : bool | None = None ,
820
822
prepared : bool = True ,
@@ -906,7 +908,7 @@ class Connection:
906
908
async def execute (
907
909
self : Self ,
908
910
querystring : str ,
909
- parameters : Sequence [ Any ] | None = None ,
911
+ parameters : ParamsT = None ,
910
912
prepared : bool = True ,
911
913
) -> QueryResult :
912
914
"""Execute the query.
@@ -990,7 +992,7 @@ class Connection:
990
992
async def fetch (
991
993
self : Self ,
992
994
querystring : str ,
993
- parameters : Sequence [ Any ] | None = None ,
995
+ parameters : ParamsT = None ,
994
996
prepared : bool = True ,
995
997
) -> QueryResult :
996
998
"""Fetch the result from database.
@@ -1010,7 +1012,7 @@ class Connection:
1010
1012
async def fetch_row (
1011
1013
self : Self ,
1012
1014
querystring : str ,
1013
- parameters : Sequence [ Any ] | None = None ,
1015
+ parameters : ParamsT = None ,
1014
1016
prepared : bool = True ,
1015
1017
) -> SingleQueryResult :
1016
1018
"""Fetch exaclty single row from query.
@@ -1046,7 +1048,7 @@ class Connection:
1046
1048
async def fetch_val (
1047
1049
self : Self ,
1048
1050
querystring : str ,
1049
- parameters : Sequence [ Any ] | None = None ,
1051
+ parameters : ParamsT = None ,
1050
1052
prepared : bool = True ,
1051
1053
) -> Any :
1052
1054
"""Execute the query and return first value of the first row.
@@ -1100,7 +1102,7 @@ class Connection:
1100
1102
def cursor (
1101
1103
self : Self ,
1102
1104
querystring : str ,
1103
- parameters : Sequence [ Any ] | None = None ,
1105
+ parameters : ParamsT = None ,
1104
1106
fetch_number : int | None = None ,
1105
1107
scroll : bool | None = None ,
1106
1108
prepared : bool = True ,
@@ -1708,10 +1710,13 @@ class ConnectionPoolBuilder:
1708
1710
self : Self ,
1709
1711
keepalives_retries : int ,
1710
1712
) -> Self :
1711
- """
1712
- Set the maximum number of TCP keepalive probes that will be sent before dropping a connection.
1713
+ """Keepalives Retries.
1714
+
1715
+ Set the maximum number of TCP keepalive probes
1716
+ that will be sent before dropping a connection.
1713
1717
1714
- This is ignored for Unix domain sockets, or if the `keepalives` option is disabled.
1718
+ This is ignored for Unix domain sockets,
1719
+ or if the `keepalives` option is disabled.
1715
1720
1716
1721
### Parameters:
1717
1722
- `keepalives_retries`: number of retries.
0 commit comments