|
1 | 1 | import types
|
2 | 2 | from enum import Enum
|
3 |
| -from typing import Any, Callable, List, Optional, TypeVar |
| 3 | +from typing import Any, Callable, List, Optional, Sequence, TypeVar |
4 | 4 |
|
5 | 5 | from typing_extensions import Self
|
6 | 6 |
|
@@ -337,7 +337,7 @@ class Transaction:
|
337 | 337 | async def execute(
|
338 | 338 | self: Self,
|
339 | 339 | querystring: str,
|
340 |
| - parameters: list[Any] | None = None, |
| 340 | + parameters: Sequence[Any] | None = None, |
341 | 341 | prepared: bool = True,
|
342 | 342 | ) -> QueryResult:
|
343 | 343 | """Execute the query.
|
@@ -375,7 +375,7 @@ class Transaction:
|
375 | 375 | async def execute_many(
|
376 | 376 | self: Self,
|
377 | 377 | querystring: str,
|
378 |
| - parameters: list[list[Any]] | None = None, |
| 378 | + parameters: Sequence[Sequence[Any]] | None = None, |
379 | 379 | prepared: bool = True,
|
380 | 380 | ) -> None: ...
|
381 | 381 | """Execute query multiple times with different parameters.
|
@@ -410,10 +410,30 @@ class Transaction:
|
410 | 410 | await transaction.commit()
|
411 | 411 | ```
|
412 | 412 | """
|
| 413 | + async def fetch( |
| 414 | + self: Self, |
| 415 | + querystring: str, |
| 416 | + parameters: Sequence[Any] | None = None, |
| 417 | + prepared: bool = True, |
| 418 | + ) -> QueryResult: |
| 419 | + """Fetch the result from database. |
| 420 | +
|
| 421 | + It's the same as `execute` method, we made it because people are used |
| 422 | + to `fetch` method name. |
| 423 | +
|
| 424 | + Querystring can contain `$<number>` parameters |
| 425 | + for converting them in the driver side. |
| 426 | +
|
| 427 | + ### Parameters: |
| 428 | + - `querystring`: querystring to execute. |
| 429 | + - `parameters`: list of parameters to pass in the query. |
| 430 | + - `prepared`: should the querystring be prepared before the request. |
| 431 | + By default any querystring will be prepared. |
| 432 | + """ |
413 | 433 | async def fetch_row(
|
414 | 434 | self: Self,
|
415 | 435 | querystring: str,
|
416 |
| - parameters: list[Any] | None = None, |
| 436 | + parameters: Sequence[Any] | None = None, |
417 | 437 | prepared: bool = True,
|
418 | 438 | ) -> SingleQueryResult:
|
419 | 439 | """Fetch exaclty single row from query.
|
@@ -453,7 +473,7 @@ class Transaction:
|
453 | 473 | async def fetch_val(
|
454 | 474 | self: Self,
|
455 | 475 | querystring: str,
|
456 |
| - parameters: list[Any] | None = None, |
| 476 | + parameters: Sequence[Any] | None = None, |
457 | 477 | prepared: bool = True,
|
458 | 478 | ) -> Any | None:
|
459 | 479 | """Execute the query and return first value of the first row.
|
@@ -661,7 +681,7 @@ class Transaction:
|
661 | 681 | def cursor(
|
662 | 682 | self: Self,
|
663 | 683 | querystring: str,
|
664 |
| - parameters: list[Any] | None = None, |
| 684 | + parameters: Sequence[Any] | None = None, |
665 | 685 | fetch_number: int | None = None,
|
666 | 686 | scroll: bool | None = None,
|
667 | 687 | prepared: bool = True,
|
@@ -717,7 +737,7 @@ class Connection:
|
717 | 737 | async def execute(
|
718 | 738 | self: Self,
|
719 | 739 | querystring: str,
|
720 |
| - parameters: list[Any] | None = None, |
| 740 | + parameters: Sequence[Any] | None = None, |
721 | 741 | prepared: bool = True,
|
722 | 742 | ) -> QueryResult:
|
723 | 743 | """Execute the query.
|
@@ -784,10 +804,30 @@ class Connection:
|
784 | 804 | )
|
785 | 805 | ```
|
786 | 806 | """
|
| 807 | + async def fetch( |
| 808 | + self: Self, |
| 809 | + querystring: str, |
| 810 | + parameters: Sequence[Any] | None = None, |
| 811 | + prepared: bool = True, |
| 812 | + ) -> QueryResult: |
| 813 | + """Fetch the result from database. |
| 814 | +
|
| 815 | + It's the same as `execute` method, we made it because people are used |
| 816 | + to `fetch` method name. |
| 817 | +
|
| 818 | + Querystring can contain `$<number>` parameters |
| 819 | + for converting them in the driver side. |
| 820 | +
|
| 821 | + ### Parameters: |
| 822 | + - `querystring`: querystring to execute. |
| 823 | + - `parameters`: list of parameters to pass in the query. |
| 824 | + - `prepared`: should the querystring be prepared before the request. |
| 825 | + By default any querystring will be prepared. |
| 826 | + """ |
787 | 827 | async def fetch_row(
|
788 | 828 | self: Self,
|
789 | 829 | querystring: str,
|
790 |
| - parameters: list[Any] | None = None, |
| 830 | + parameters: Sequence[Any] | None = None, |
791 | 831 | prepared: bool = True,
|
792 | 832 | ) -> SingleQueryResult:
|
793 | 833 | """Fetch exaclty single row from query.
|
@@ -824,7 +864,7 @@ class Connection:
|
824 | 864 | async def fetch_val(
|
825 | 865 | self: Self,
|
826 | 866 | querystring: str,
|
827 |
| - parameters: list[Any] | None = None, |
| 867 | + parameters: Sequence[Any] | None = None, |
828 | 868 | prepared: bool = True,
|
829 | 869 | ) -> Any:
|
830 | 870 | """Execute the query and return first value of the first row.
|
@@ -979,7 +1019,7 @@ class ConnectionPool:
|
979 | 1019 | async def execute(
|
980 | 1020 | self: Self,
|
981 | 1021 | querystring: str,
|
982 |
| - parameters: list[Any] | None = None, |
| 1022 | + parameters: Sequence[Any] | None = None, |
983 | 1023 | prepared: bool = True,
|
984 | 1024 | ) -> QueryResult:
|
985 | 1025 | """Execute the query.
|
@@ -1011,6 +1051,26 @@ class ConnectionPool:
|
1011 | 1051 | # it will be dropped on Rust side.
|
1012 | 1052 | ```
|
1013 | 1053 | """
|
| 1054 | + async def fetch( |
| 1055 | + self: Self, |
| 1056 | + querystring: str, |
| 1057 | + parameters: Sequence[Any] | None = None, |
| 1058 | + prepared: bool = True, |
| 1059 | + ) -> QueryResult: |
| 1060 | + """Fetch the result from database. |
| 1061 | +
|
| 1062 | + It's the same as `execute` method, we made it because people are used |
| 1063 | + to `fetch` method name. |
| 1064 | +
|
| 1065 | + Querystring can contain `$<number>` parameters |
| 1066 | + for converting them in the driver side. |
| 1067 | +
|
| 1068 | + ### Parameters: |
| 1069 | + - `querystring`: querystring to execute. |
| 1070 | + - `parameters`: list of parameters to pass in the query. |
| 1071 | + - `prepared`: should the querystring be prepared before the request. |
| 1072 | + By default any querystring will be prepared. |
| 1073 | + """ |
1014 | 1074 | async def connection(self: Self) -> Connection:
|
1015 | 1075 | """Create new connection.
|
1016 | 1076 |
|
|
0 commit comments