Skip to content

Commit e1811e6

Browse files
authored
Merge pull request #25 from qaspen-python/feature/fix_type_annotations
Fixed type hint mistakes in python pyi files
2 parents c8b3d7b + a41745d commit e1811e6

File tree

2 files changed

+13
-53
lines changed

2 files changed

+13
-53
lines changed

README.md

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -62,34 +62,6 @@ async def main() -> None:
6262

6363
```
6464

65-
Or you can create connection pool with this function:
66-
67-
```python
68-
from typing import Any
69-
70-
from psqlpy import PSQLPool, QueryResult, create_connection_pool
71-
72-
73-
db_pool: PSQLPool = create_connection_pool(
74-
username="postgres",
75-
password="pg_password",
76-
host="localhost",
77-
port=5432,
78-
db_name="postgres",
79-
max_db_pool_size=2,
80-
)
81-
82-
async def main() -> None:
83-
res: QueryResult = await db_pool.execute(
84-
"SELECT * FROM users",
85-
)
86-
87-
print(res.result())
88-
# You don't need to close Database Pool by yourself,
89-
# rust does it instead.
90-
91-
```
92-
9365
Please take into account that each new execute gets new connection from connection pool.
9466

9567
### DSN support

python/psqlpy/_internal/__init__.pyi

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,8 @@ class Transaction:
437437
) -> Any | None:
438438
"""Execute the query and return first value of the first row.
439439
440+
Returns an error if the query does not return exactly one row.
441+
440442
Querystring can contain `$<number>` parameters
441443
for converting them in the driver side.
442444
@@ -446,6 +448,10 @@ class Transaction:
446448
- `prepared`: should the querystring be prepared before the request.
447449
By default any querystring will be prepared.
448450
451+
### Raises
452+
- `RustPSQLDriverPyBaseError`: if the query does not
453+
return exactly one row
454+
449455
### Example:
450456
```python
451457
import asyncio
@@ -799,9 +805,11 @@ class Connection:
799805
querystring: str,
800806
parameters: list[Any] | None = None,
801807
prepared: bool = True,
802-
) -> Any | None:
808+
) -> Any:
803809
"""Execute the query and return first value of the first row.
804810
811+
Returns an error if the query does not return exactly one row.
812+
805813
Querystring can contain `$<number>` parameters
806814
for converting them in the driver side.
807815
@@ -811,6 +819,10 @@ class Connection:
811819
- `prepared`: should the querystring be prepared before the request.
812820
By default any querystring will be prepared.
813821
822+
### Raises
823+
- `RustPSQLDriverPyBaseError`: if the query does not
824+
return exactly one row
825+
814826
### Example:
815827
```python
816828
import asyncio
@@ -928,27 +940,3 @@ class PSQLPool:
928940
929941
It acquires new connection from the database pool.
930942
"""
931-
932-
def create_connection_pool(
933-
dsn: Optional[str] = None,
934-
username: Optional[str] = None,
935-
password: Optional[str] = None,
936-
host: Optional[str] = None,
937-
port: Optional[int] = None,
938-
db_name: Optional[str] = None,
939-
max_db_pool_size: int = 2,
940-
conn_recycling_method: Optional[ConnRecyclingMethod] = None,
941-
) -> PSQLPool:
942-
"""Create new connection pool.
943-
944-
### Parameters:
945-
- `dsn`: full dsn connection string.
946-
`postgres://postgres:postgres@localhost:5432/postgres?target_session_attrs=read-write`
947-
- `username`: username of the user in postgres
948-
- `password`: password of the user in postgres
949-
- `host`: host of postgres
950-
- `port`: port of postgres
951-
- `db_name`: name of the database in postgres
952-
- `max_db_pool_size`: maximum size of the connection pool
953-
- `conn_recycling_method`: how a connection is recycled.
954-
"""

0 commit comments

Comments
 (0)