tracktolib 0.56.0__py3-none-any.whl → 0.57.0__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.
tracktolib/pg_sync.py CHANGED
@@ -1,5 +1,5 @@
1
1
  from pathlib import Path
2
- from typing import Iterable, Any, overload, Literal, cast, Optional
2
+ from typing import Iterable, Any, overload, Literal, cast, Optional, Mapping, Sequence
3
3
 
4
4
  from typing_extensions import LiteralString
5
5
 
@@ -67,20 +67,22 @@ def fetch_one(engine: Connection, query: Query, *args, required: bool = False) -
67
67
  return _data
68
68
 
69
69
 
70
- def _parse_value(v):
70
+ def _parse_value(v: Any) -> Any:
71
71
  if isinstance(v, dict):
72
72
  return Json(v)
73
73
  return v
74
74
 
75
75
 
76
- def get_insert_data(table: LiteralString, data: list[dict]) -> tuple[LiteralString, list[tuple[Any, ...]]]:
76
+ def get_insert_data(
77
+ table: LiteralString, data: Sequence[Mapping[str, Any]]
78
+ ) -> tuple[LiteralString, list[tuple[Any, ...]]]:
77
79
  keys = data[0].keys()
78
80
  _values = ",".join("%s" for _ in range(0, len(keys)))
79
- query = f"INSERT INTO {table} as t ({','.join(keys)}) VALUES ({_values})"
81
+ query = cast(LiteralString, f"INSERT INTO {table} as t ({','.join(keys)}) VALUES ({_values})")
80
82
  return query, [tuple(_parse_value(_x) for _x in x.values()) for x in data]
81
83
 
82
84
 
83
- def insert_many(engine: Connection | Cursor, table: LiteralString, data: list[dict]):
85
+ def insert_many(engine: Connection | Cursor, table: LiteralString, data: Sequence[Mapping[str, Any]]):
84
86
  query, _data = get_insert_data(table, data)
85
87
  if isinstance(engine, Connection):
86
88
  with engine.cursor() as cur:
@@ -92,15 +94,17 @@ def insert_many(engine: Connection | Cursor, table: LiteralString, data: list[di
92
94
 
93
95
 
94
96
  @overload
95
- def insert_one(engine: Connection, table: LiteralString, data: dict, returning: None = None) -> None: ...
97
+ def insert_one(engine: Connection, table: LiteralString, data: Mapping[str, Any], returning: None = None) -> None: ...
96
98
 
97
99
 
98
100
  @overload
99
- def insert_one(engine: Connection, table: LiteralString, data: dict, returning: list[LiteralString]) -> dict: ...
101
+ def insert_one(
102
+ engine: Connection, table: LiteralString, data: Mapping[str, Any], returning: list[LiteralString]
103
+ ) -> dict: ...
100
104
 
101
105
 
102
106
  def insert_one(
103
- engine: Connection, table: LiteralString, data: dict, returning: list[LiteralString] | None = None
107
+ engine: Connection, table: LiteralString, data: Mapping[str, Any], returning: list[LiteralString] | None = None
104
108
  ) -> dict | None:
105
109
  query, _data = get_insert_data(table, [data])
106
110
  _is_returning = False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: tracktolib
3
- Version: 0.56.0
3
+ Version: 0.57.0
4
4
  Summary: Utility library for python
5
5
  License: MIT
6
6
  Keywords: utility
@@ -5,14 +5,14 @@ tracktolib/logs.py,sha256=xgfRDnviZPr9qinSOgab8neIWPv9Rj2xzDHnIBvWQcU,2201
5
5
  tracktolib/pg/__init__.py,sha256=j67e3B3gBbCHLD20QBybptmNdbbVMzNhZE6XjIPuKVo,349
6
6
  tracktolib/pg/query.py,sha256=MBYOTL9aLnYRBhaLy8-P6uGNXOmyluejNyUdt3Gfx5M,14504
7
7
  tracktolib/pg/utils.py,sha256=cL24KEt4SWJQ7LJPzaO3c8Xg0ZLmjhn22DtTWg86nwc,6324
8
- tracktolib/pg_sync.py,sha256=82fh2XUlH55veWkdIRfirOSjGUWwK759U51ZsBXc2_U,6214
8
+ tracktolib/pg_sync.py,sha256=snfYtj5ICWa2C_QWRFKZecHPgVx1yhofhGst0e6CGxs,6351
9
9
  tracktolib/pg_utils.py,sha256=VXPpy1jGq6aCgTlfFJDIrq6JDujR83JN5ZRiCi8Lx4E,2582
10
10
  tracktolib/s3/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  tracktolib/s3/minio.py,sha256=wMEjkSes9Fp39fD17IctALpD6zB2xwDRQEmO7Vzan3g,1387
12
12
  tracktolib/s3/s3.py,sha256=0HbSAPoaup5-W4LK54zRCjrQ5mr8OWR-N9WjW99Q4aw,5937
13
13
  tracktolib/tests.py,sha256=gKE--epQjgMZGXc5ydbl4zjOdmwztJS42UMV0p4hXEA,399
14
14
  tracktolib/utils.py,sha256=ysTBF9V35fVXQVBPk0kfE_84SGRxzrayqmg9RbtoJq4,5761
15
- tracktolib-0.56.0.dist-info/LICENSE,sha256=uUanH0X7SeZEPdsRTHegMSMTiIHMurt9H0jSwEwKE1Y,1081
16
- tracktolib-0.56.0.dist-info/METADATA,sha256=kigOjHx1QJ-xf6L0tUnhJUiZiYMB6VDGso-yzuspREk,3704
17
- tracktolib-0.56.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
18
- tracktolib-0.56.0.dist-info/RECORD,,
15
+ tracktolib-0.57.0.dist-info/LICENSE,sha256=uUanH0X7SeZEPdsRTHegMSMTiIHMurt9H0jSwEwKE1Y,1081
16
+ tracktolib-0.57.0.dist-info/METADATA,sha256=88PzWoI3eX1blMUAWEHUzuYFPWndH7O0sCPr9_ScSNE,3704
17
+ tracktolib-0.57.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
18
+ tracktolib-0.57.0.dist-info/RECORD,,