-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.py
More file actions
68 lines (46 loc) · 1.59 KB
/
Copy pathtypes.py
File metadata and controls
68 lines (46 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
"""Type definitions for pgsql-test."""
from dataclasses import dataclass
from typing import Any, Protocol, TypedDict
class PgConfig(TypedDict, total=False):
"""PostgreSQL connection configuration."""
host: str
port: int
database: str
user: str
password: str
class ConnectionOptions(TypedDict, total=False):
"""Options for database connections."""
prefix: str # Prefix for test database names
root_db: str # Root database for admin operations (default: postgres)
extensions: list[str] # Extensions to install
template: str | None # Template database to use
@dataclass
class ConnectionResult:
"""Result from get_connections()."""
pg: Any # PgTestClient connected as superuser
db: Any # PgTestClient connected as app user
admin: Any # DbAdmin instance
manager: Any # PgTestConnector instance
teardown: Any # Callable to teardown connections
class SeedContext(TypedDict):
"""Context passed to seed adapters."""
config: PgConfig
admin: Any # DbAdmin
pg: Any # PgTestClient
class SeedAdapter(Protocol):
"""Protocol for seed adapters."""
async def seed(self, ctx: SeedContext) -> None:
"""Execute the seeding operation."""
...
@dataclass
class QueryResult:
"""Result from a database query."""
rows: list[dict[str, Any]]
row_count: int
status_message: str | None = None
def __iter__(self) -> Any:
return iter(self.rows)
def __len__(self) -> int:
return len(self.rows)
def __getitem__(self, index: int) -> dict[str, Any]:
return self.rows[index]