tracktolib 0.53.1__tar.gz → 0.55.0__tar.gz
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-0.53.1 → tracktolib-0.55.0}/PKG-INFO +3 -3
- {tracktolib-0.53.1 → tracktolib-0.55.0}/pyproject.toml +3 -3
- {tracktolib-0.53.1 → tracktolib-0.55.0}/tracktolib/api.py +15 -0
- {tracktolib-0.53.1 → tracktolib-0.55.0}/tracktolib/pg_sync.py +40 -5
- {tracktolib-0.53.1 → tracktolib-0.55.0}/LICENSE +0 -0
- {tracktolib-0.53.1 → tracktolib-0.55.0}/README.md +0 -0
- {tracktolib-0.53.1 → tracktolib-0.55.0}/tracktolib/__init__.py +0 -0
- {tracktolib-0.53.1 → tracktolib-0.55.0}/tracktolib/http_utils.py +0 -0
- {tracktolib-0.53.1 → tracktolib-0.55.0}/tracktolib/logs.py +0 -0
- {tracktolib-0.53.1 → tracktolib-0.55.0}/tracktolib/pg/__init__.py +0 -0
- {tracktolib-0.53.1 → tracktolib-0.55.0}/tracktolib/pg/query.py +0 -0
- {tracktolib-0.53.1 → tracktolib-0.55.0}/tracktolib/pg/utils.py +0 -0
- {tracktolib-0.53.1 → tracktolib-0.55.0}/tracktolib/pg_utils.py +0 -0
- {tracktolib-0.53.1 → tracktolib-0.55.0}/tracktolib/s3/__init__.py +0 -0
- {tracktolib-0.53.1 → tracktolib-0.55.0}/tracktolib/s3/minio.py +0 -0
- {tracktolib-0.53.1 → tracktolib-0.55.0}/tracktolib/s3/s3.py +0 -0
- {tracktolib-0.53.1 → tracktolib-0.55.0}/tracktolib/tests.py +0 -0
- {tracktolib-0.53.1 → tracktolib-0.55.0}/tracktolib/utils.py +0 -0
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: tracktolib
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.55.0
|
|
4
4
|
Summary: Utility library for python
|
|
5
|
-
Home-page: https://github.com/tracktor/tracktolib
|
|
6
5
|
License: MIT
|
|
7
6
|
Keywords: utility
|
|
8
7
|
Author: Julien Brayere
|
|
@@ -32,6 +31,7 @@ Requires-Dist: pycryptodome (>=3.20.0) ; extra == "s3-minio"
|
|
|
32
31
|
Requires-Dist: pydantic (>=2) ; extra == "api"
|
|
33
32
|
Requires-Dist: python-json-logger (>=3.2.1) ; extra == "logs"
|
|
34
33
|
Requires-Dist: rich (>=13.6.0) ; extra == "pg"
|
|
34
|
+
Project-URL: Homepage, https://github.com/tracktor/tracktolib
|
|
35
35
|
Project-URL: Repository, https://github.com/tracktor/tracktolib
|
|
36
36
|
Description-Content-Type: text/markdown
|
|
37
37
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "tracktolib"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.55.0"
|
|
4
4
|
description = "Utility library for python"
|
|
5
5
|
authors = ["Julien Brayere <julien.brayere@tracktor.fr>"]
|
|
6
6
|
license = "MIT"
|
|
@@ -55,7 +55,7 @@ httpx = "^0.27.0"
|
|
|
55
55
|
psycopg = "^3.2.1"
|
|
56
56
|
minio = "^7.2.7"
|
|
57
57
|
pycryptodome = "^3.20.0"
|
|
58
|
-
aiobotocore = "
|
|
58
|
+
aiobotocore = "2.15.2"
|
|
59
59
|
python-json-logger = "^3.2.0"
|
|
60
60
|
|
|
61
61
|
|
|
@@ -83,7 +83,7 @@ pythonPlatform = "Linux"
|
|
|
83
83
|
|
|
84
84
|
[tool.commitizen]
|
|
85
85
|
name = "cz_conventional_commits"
|
|
86
|
-
version = "0.
|
|
86
|
+
version = "0.55.0"
|
|
87
87
|
tag_format = "$version"
|
|
88
88
|
version_files = [
|
|
89
89
|
"pyproject.toml:version"
|
|
@@ -69,6 +69,7 @@ class MethodMeta(TypedDict):
|
|
|
69
69
|
name: str | None
|
|
70
70
|
summary: str | None
|
|
71
71
|
description: str | None
|
|
72
|
+
deprecated: bool | None
|
|
72
73
|
|
|
73
74
|
|
|
74
75
|
@dataclass
|
|
@@ -89,6 +90,7 @@ class Endpoint:
|
|
|
89
90
|
name: str | None = None,
|
|
90
91
|
summary: str | None = None,
|
|
91
92
|
description: str | None = None,
|
|
93
|
+
deprecated: bool | None = None,
|
|
92
94
|
):
|
|
93
95
|
return _get_method_wrapper(
|
|
94
96
|
cls=self,
|
|
@@ -101,6 +103,7 @@ class Endpoint:
|
|
|
101
103
|
name=name,
|
|
102
104
|
summary=summary,
|
|
103
105
|
description=description,
|
|
106
|
+
deprecated=deprecated,
|
|
104
107
|
)
|
|
105
108
|
|
|
106
109
|
def post(
|
|
@@ -114,6 +117,7 @@ class Endpoint:
|
|
|
114
117
|
name: str | None = None,
|
|
115
118
|
summary: str | None = None,
|
|
116
119
|
description: str | None = None,
|
|
120
|
+
deprecated: bool | None = None,
|
|
117
121
|
):
|
|
118
122
|
return _get_method_wrapper(
|
|
119
123
|
cls=self,
|
|
@@ -126,6 +130,7 @@ class Endpoint:
|
|
|
126
130
|
name=name,
|
|
127
131
|
summary=summary,
|
|
128
132
|
description=description,
|
|
133
|
+
deprecated=deprecated,
|
|
129
134
|
)
|
|
130
135
|
|
|
131
136
|
def put(
|
|
@@ -138,6 +143,7 @@ class Endpoint:
|
|
|
138
143
|
name: str | None = None,
|
|
139
144
|
summary: str | None = None,
|
|
140
145
|
description: str | None = None,
|
|
146
|
+
deprecated: bool | None = None,
|
|
141
147
|
):
|
|
142
148
|
return _get_method_wrapper(
|
|
143
149
|
cls=self,
|
|
@@ -150,6 +156,7 @@ class Endpoint:
|
|
|
150
156
|
name=name,
|
|
151
157
|
summary=summary,
|
|
152
158
|
description=description,
|
|
159
|
+
deprecated=deprecated,
|
|
153
160
|
)
|
|
154
161
|
|
|
155
162
|
def delete(
|
|
@@ -162,6 +169,7 @@ class Endpoint:
|
|
|
162
169
|
name: str | None = None,
|
|
163
170
|
summary: str | None = None,
|
|
164
171
|
description: str | None = None,
|
|
172
|
+
deprecated: bool | None = None,
|
|
165
173
|
):
|
|
166
174
|
return _get_method_wrapper(
|
|
167
175
|
cls=self,
|
|
@@ -174,6 +182,7 @@ class Endpoint:
|
|
|
174
182
|
name=name,
|
|
175
183
|
summary=summary,
|
|
176
184
|
description=description,
|
|
185
|
+
deprecated=deprecated,
|
|
177
186
|
)
|
|
178
187
|
|
|
179
188
|
def patch(
|
|
@@ -186,6 +195,7 @@ class Endpoint:
|
|
|
186
195
|
name: str | None = None,
|
|
187
196
|
summary: str | None = None,
|
|
188
197
|
description: str | None = None,
|
|
198
|
+
deprecated: bool | None = None,
|
|
189
199
|
):
|
|
190
200
|
return _get_method_wrapper(
|
|
191
201
|
cls=self,
|
|
@@ -198,6 +208,7 @@ class Endpoint:
|
|
|
198
208
|
name=name,
|
|
199
209
|
summary=summary,
|
|
200
210
|
description=description,
|
|
211
|
+
deprecated=deprecated,
|
|
201
212
|
)
|
|
202
213
|
|
|
203
214
|
|
|
@@ -213,6 +224,7 @@ def _get_method_wrapper(
|
|
|
213
224
|
name: str | None = None,
|
|
214
225
|
summary: str | None = None,
|
|
215
226
|
description: str | None = None,
|
|
227
|
+
deprecated: bool | None = None,
|
|
216
228
|
):
|
|
217
229
|
def _set_method_wrapper(func: EnpointFn):
|
|
218
230
|
if model is not None:
|
|
@@ -232,6 +244,7 @@ def _get_method_wrapper(
|
|
|
232
244
|
"name": name,
|
|
233
245
|
"summary": summary,
|
|
234
246
|
"description": description,
|
|
247
|
+
"deprecated": deprecated,
|
|
235
248
|
}
|
|
236
249
|
cls._methods[method] = _meta
|
|
237
250
|
|
|
@@ -265,6 +278,7 @@ def add_endpoint(
|
|
|
265
278
|
_name = _meta.get("name")
|
|
266
279
|
_summary = _meta.get("summary")
|
|
267
280
|
_description = _meta.get("description")
|
|
281
|
+
_deprecated = _meta.get("deprecated")
|
|
268
282
|
if not _response_model:
|
|
269
283
|
try:
|
|
270
284
|
_response_model = _get_return_type(_fn)
|
|
@@ -292,6 +306,7 @@ def add_endpoint(
|
|
|
292
306
|
status_code=_status_code,
|
|
293
307
|
dependencies=[*(_dependencies or []), *(dependencies or [])],
|
|
294
308
|
openapi_extra=_meta.get("openapi_extra"),
|
|
309
|
+
deprecated=_deprecated,
|
|
295
310
|
)
|
|
296
311
|
|
|
297
312
|
|
|
@@ -15,6 +15,21 @@ except ImportError:
|
|
|
15
15
|
from .pg_utils import get_tmp_table_query
|
|
16
16
|
|
|
17
17
|
|
|
18
|
+
__all__ = (
|
|
19
|
+
"clean_tables",
|
|
20
|
+
"drop_db",
|
|
21
|
+
"fetch_all",
|
|
22
|
+
"fetch_count",
|
|
23
|
+
"fetch_one",
|
|
24
|
+
"get_insert_data",
|
|
25
|
+
"get_tables",
|
|
26
|
+
"insert_many",
|
|
27
|
+
"insert_one",
|
|
28
|
+
"insert_csv",
|
|
29
|
+
"set_seq_max",
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
|
|
18
33
|
def fetch_all(engine: Connection, query: LiteralString, *data) -> list[dict]:
|
|
19
34
|
with engine.cursor(row_factory=dict_row) as cur:
|
|
20
35
|
resp = (cur.execute(query) if not data else cur.execute(query, data)).fetchall()
|
|
@@ -59,7 +74,7 @@ def _parse_value(v):
|
|
|
59
74
|
return v
|
|
60
75
|
|
|
61
76
|
|
|
62
|
-
def
|
|
77
|
+
def get_insert_data(table: LiteralString, data: list[dict]) -> tuple[LiteralString, list[tuple[Any, ...]]]:
|
|
63
78
|
keys = data[0].keys()
|
|
64
79
|
_values = ",".join("%s" for _ in range(0, len(keys)))
|
|
65
80
|
query = f"INSERT INTO {table} as t ({','.join(keys)}) VALUES ({_values})"
|
|
@@ -67,17 +82,37 @@ def _get_insert_data(table: LiteralString, data: list[dict]) -> tuple[LiteralStr
|
|
|
67
82
|
|
|
68
83
|
|
|
69
84
|
def insert_many(engine: Connection, table: LiteralString, data: list[dict]):
|
|
70
|
-
query, _data =
|
|
85
|
+
query, _data = get_insert_data(table, data)
|
|
71
86
|
with engine.cursor() as cur:
|
|
72
87
|
_ = cur.executemany(query, _data)
|
|
73
88
|
engine.commit()
|
|
74
89
|
|
|
75
90
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
91
|
+
@overload
|
|
92
|
+
def insert_one(engine: Connection, table: LiteralString, data: dict, returning: None = None) -> None: ...
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
@overload
|
|
96
|
+
def insert_one(engine: Connection, table: LiteralString, data: dict, returning: list[LiteralString]) -> dict: ...
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def insert_one(
|
|
100
|
+
engine: Connection, table: LiteralString, data: dict, returning: list[LiteralString] | None = None
|
|
101
|
+
) -> dict | None:
|
|
102
|
+
query, _data = get_insert_data(table, [data])
|
|
103
|
+
_is_returning = False
|
|
104
|
+
if returning:
|
|
105
|
+
query = f"{query} RETURNING {','.join(returning)}"
|
|
106
|
+
_is_returning = True
|
|
107
|
+
|
|
108
|
+
with engine.cursor(row_factory=dict_row) as cur:
|
|
79
109
|
_ = cur.execute(query, _data[0])
|
|
110
|
+
if _is_returning:
|
|
111
|
+
resp = cur.fetchone()
|
|
112
|
+
else:
|
|
113
|
+
resp = None
|
|
80
114
|
engine.commit()
|
|
115
|
+
return resp
|
|
81
116
|
|
|
82
117
|
|
|
83
118
|
def drop_db(conn: Connection, db_name: LiteralString):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|