latch-postgres 0.1.18__py3-none-any.whl → 0.1.20__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- latch_postgres/postgres.py +12 -43
- latch_postgres-0.1.20.dist-info/METADATA +18 -0
- latch_postgres-0.1.20.dist-info/RECORD +8 -0
- {latch_postgres-0.1.18.dist-info → latch_postgres-0.1.20.dist-info}/WHEEL +1 -1
- latch_postgres-0.1.18.dist-info/METADATA +0 -22
- latch_postgres-0.1.18.dist-info/RECORD +0 -8
- {latch_postgres-0.1.18.dist-info → latch_postgres-0.1.20.dist-info/licenses}/LICENSE +0 -0
latch_postgres/postgres.py
CHANGED
|
@@ -1,21 +1,12 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
import functools
|
|
3
3
|
import random
|
|
4
|
+
from collections.abc import AsyncGenerator, Awaitable, Callable, Iterable
|
|
4
5
|
from contextlib import asynccontextmanager
|
|
5
6
|
from dataclasses import dataclass
|
|
6
7
|
from datetime import timedelta
|
|
7
8
|
from textwrap import dedent
|
|
8
|
-
from typing import
|
|
9
|
-
Any,
|
|
10
|
-
AsyncGenerator,
|
|
11
|
-
Awaitable,
|
|
12
|
-
Callable,
|
|
13
|
-
Concatenate,
|
|
14
|
-
Iterable,
|
|
15
|
-
ParamSpec,
|
|
16
|
-
TypeVar,
|
|
17
|
-
cast,
|
|
18
|
-
)
|
|
9
|
+
from typing import Any, Concatenate, ParamSpec, TypeVar, cast
|
|
19
10
|
|
|
20
11
|
import psycopg.sql as sql
|
|
21
12
|
from latch_config.config import PostgresConnectionConfig
|
|
@@ -37,9 +28,6 @@ from psycopg.errors import (
|
|
|
37
28
|
DeadlockDetected,
|
|
38
29
|
DiskFull,
|
|
39
30
|
DuplicateFile,
|
|
40
|
-
)
|
|
41
|
-
from psycopg.errors import Error as PGError
|
|
42
|
-
from psycopg.errors import (
|
|
43
31
|
IdleSessionTimeout,
|
|
44
32
|
InsufficientResources,
|
|
45
33
|
IoError,
|
|
@@ -55,6 +43,7 @@ from psycopg.errors import (
|
|
|
55
43
|
TooManyConnections,
|
|
56
44
|
UndefinedFile,
|
|
57
45
|
)
|
|
46
|
+
from psycopg.errors import Error as PGError
|
|
58
47
|
from psycopg.rows import AsyncRowFactory, Row, dict_row, kwargs_row
|
|
59
48
|
from psycopg.types.composite import CompositeInfo, register_composite
|
|
60
49
|
from psycopg.types.enum import EnumInfo, register_enum
|
|
@@ -158,15 +147,9 @@ class LatchAsyncConnection(AsyncConnection[Row]):
|
|
|
158
147
|
trace_attributes: Attributes
|
|
159
148
|
|
|
160
149
|
def cursor(
|
|
161
|
-
self,
|
|
162
|
-
row_factory: AsyncRowFactory[Any],
|
|
163
|
-
*,
|
|
164
|
-
binary: bool = True,
|
|
150
|
+
self, row_factory: AsyncRowFactory[Any], *, binary: bool = True
|
|
165
151
|
) -> AsyncCursor[Any]:
|
|
166
|
-
res = super().cursor(
|
|
167
|
-
row_factory=row_factory,
|
|
168
|
-
binary=binary,
|
|
169
|
-
)
|
|
152
|
+
res = super().cursor(row_factory=row_factory, binary=binary)
|
|
170
153
|
assert isinstance(res, TracedAsyncCursor)
|
|
171
154
|
res.trace_attributes = self.trace_attributes
|
|
172
155
|
return res
|
|
@@ -291,18 +274,12 @@ class TracedAsyncConnectionPool(AsyncConnectionPool):
|
|
|
291
274
|
)
|
|
292
275
|
|
|
293
276
|
async def run_setup(cmd: sql.SQL):
|
|
294
|
-
with tracer.start_as_current_span(
|
|
295
|
-
"setup command",
|
|
296
|
-
):
|
|
277
|
+
with tracer.start_as_current_span("setup command"):
|
|
297
278
|
await conn.query_opt(dict, cmd)
|
|
298
279
|
|
|
299
280
|
async def run_composite_setup():
|
|
300
|
-
with tracer.start_as_current_span(
|
|
301
|
-
"composite
|
|
302
|
-
):
|
|
303
|
-
with tracer.start_as_current_span(
|
|
304
|
-
"register composite types",
|
|
305
|
-
):
|
|
281
|
+
with tracer.start_as_current_span("composite type setup"):
|
|
282
|
+
with tracer.start_as_current_span("register composite types"):
|
|
306
283
|
for db_type, f in self.composite_type_map.items():
|
|
307
284
|
type_info = await CompositeInfo.fetch(conn, db_type)
|
|
308
285
|
if type_info is None:
|
|
@@ -312,12 +289,8 @@ class TracedAsyncConnectionPool(AsyncConnectionPool):
|
|
|
312
289
|
register_composite(type_info, conn, f)
|
|
313
290
|
|
|
314
291
|
async def run_enum_setup():
|
|
315
|
-
with tracer.start_as_current_span(
|
|
316
|
-
"
|
|
317
|
-
):
|
|
318
|
-
with tracer.start_as_current_span(
|
|
319
|
-
"fetch type info",
|
|
320
|
-
):
|
|
292
|
+
with tracer.start_as_current_span("enum setup"):
|
|
293
|
+
with tracer.start_as_current_span("fetch type info"):
|
|
321
294
|
# query from
|
|
322
295
|
# https://github.com/psycopg/psycopg/blob/fd1659118e96a48f22b4e67ff17c2cdab8bd0e84/psycopg/psycopg/_typeinfo.py#L148
|
|
323
296
|
raw_responses = await conn.queryn(
|
|
@@ -406,9 +379,7 @@ class TracedAsyncConnectionPool(AsyncConnectionPool):
|
|
|
406
379
|
|
|
407
380
|
async def getconn(self, timeout: float | None = None) -> AsyncConnection[object]:
|
|
408
381
|
with tracer.start_as_current_span(
|
|
409
|
-
"postgres.connect",
|
|
410
|
-
kind=SpanKind.CLIENT,
|
|
411
|
-
attributes=self._trace_attributes,
|
|
382
|
+
"postgres.connect", kind=SpanKind.CLIENT, attributes=self._trace_attributes
|
|
412
383
|
):
|
|
413
384
|
return await super().getconn(timeout)
|
|
414
385
|
|
|
@@ -443,9 +414,7 @@ def mixin_dict(a: dict[str, object], b: dict[str, object]):
|
|
|
443
414
|
def pg_error_to_dict(x: PGError, *, short: bool = False):
|
|
444
415
|
diagnostic_obj = {
|
|
445
416
|
"severity": x.diag.severity,
|
|
446
|
-
"message": {
|
|
447
|
-
"detail": x.diag.message_detail,
|
|
448
|
-
},
|
|
417
|
+
"message": {"detail": x.diag.message_detail},
|
|
449
418
|
}
|
|
450
419
|
|
|
451
420
|
if not short:
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: latch-postgres
|
|
3
|
+
Version: 0.1.20
|
|
4
|
+
Summary: Postges wrapper for latch python backend services
|
|
5
|
+
Author-email: maximsmol <max@latch.bio>
|
|
6
|
+
License: CC0-1.0
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Python: >=3.11
|
|
9
|
+
Requires-Dist: latch-config<1.0.0,>=0.1.6
|
|
10
|
+
Requires-Dist: latch-data-validation<1.0.0,>=0.1.10
|
|
11
|
+
Requires-Dist: latch-o11y<2.0.0,>=1.0.0
|
|
12
|
+
Requires-Dist: opentelemetry-api<2.0.0,>=1.15.0
|
|
13
|
+
Requires-Dist: opentelemetry-sdk<2.0.0,>=1.15.0
|
|
14
|
+
Requires-Dist: psycopg[binary,pool]<4.0.0,>=3.1.8
|
|
15
|
+
Requires-Dist: typing-extensions<5.0.0,>=4.4.0
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
|
|
18
|
+
# python-postgres
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
latch_postgres/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
latch_postgres/postgres.py,sha256=EtrOpQN7VO1_dFFY_Gpivrv9p47mS-YGWh_NCYoy2L4,24441
|
|
3
|
+
latch_postgres/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
latch_postgres/retries.py,sha256=r5yH00fd_6EJNYFXAq3dAljJBphScpoeST-_oMvyj8Q,1308
|
|
5
|
+
latch_postgres-0.1.20.dist-info/METADATA,sha256=B3RxN3paL3WpYQV6XLpThnVmgKZUD5a4Jd0perGWag4,607
|
|
6
|
+
latch_postgres-0.1.20.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
7
|
+
latch_postgres-0.1.20.dist-info/licenses/LICENSE,sha256=wh3JZu6ITG7ceN-1g404ekupj5JXAw4pnQ_Qr4sJfew,7052
|
|
8
|
+
latch_postgres-0.1.20.dist-info/RECORD,,
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: latch-postgres
|
|
3
|
-
Version: 0.1.18
|
|
4
|
-
Summary: Postges wrapper for latch python backend services
|
|
5
|
-
License: CC0 1.0
|
|
6
|
-
Author: Max Smolin
|
|
7
|
-
Author-email: max@latch.bio
|
|
8
|
-
Requires-Python: >=3.11,<4.0
|
|
9
|
-
Classifier: License :: Other/Proprietary License
|
|
10
|
-
Classifier: Programming Language :: Python :: 3
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
-
Requires-Dist: latch-config (>=0.1.6,<0.2.0)
|
|
13
|
-
Requires-Dist: latch-data-validation (>=0.1.3,<0.2.0)
|
|
14
|
-
Requires-Dist: latch-o11y (>=0.1.4,<0.2.0)
|
|
15
|
-
Requires-Dist: opentelemetry-api (>=1.15.0,<2.0.0)
|
|
16
|
-
Requires-Dist: opentelemetry-sdk (>=1.15.0,<2.0.0)
|
|
17
|
-
Requires-Dist: psycopg[binary,pool] (>=3.1.8,<4.0.0)
|
|
18
|
-
Requires-Dist: typing-extensions (>=4.4.0,<5.0.0)
|
|
19
|
-
Description-Content-Type: text/markdown
|
|
20
|
-
|
|
21
|
-
# python-postgres
|
|
22
|
-
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
latch_postgres/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
latch_postgres/postgres.py,sha256=tGUhVLq5J4tyNrKt4xiRf-RlkqFNrUZ9Jl7WEHLqIPQ,24845
|
|
3
|
-
latch_postgres/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
latch_postgres/retries.py,sha256=r5yH00fd_6EJNYFXAq3dAljJBphScpoeST-_oMvyj8Q,1308
|
|
5
|
-
latch_postgres-0.1.18.dist-info/LICENSE,sha256=wh3JZu6ITG7ceN-1g404ekupj5JXAw4pnQ_Qr4sJfew,7052
|
|
6
|
-
latch_postgres-0.1.18.dist-info/WHEEL,sha256=vVCvjcmxuUltf8cYhJ0sJMRDLr1XsPuxEId8YDzbyCY,88
|
|
7
|
-
latch_postgres-0.1.18.dist-info/METADATA,sha256=DJH9BWZExD7p8dHfq96obvOJ7zoJVvOujWgyAV-k8tI,766
|
|
8
|
-
latch_postgres-0.1.18.dist-info/RECORD,,
|
|
File without changes
|