tracktolib 0.36.0__py3-none-any.whl → 0.37.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/utils.py +9 -4
- {tracktolib-0.36.0.dist-info → tracktolib-0.37.0.dist-info}/METADATA +1 -1
- {tracktolib-0.36.0.dist-info → tracktolib-0.37.0.dist-info}/RECORD +5 -5
- {tracktolib-0.36.0.dist-info → tracktolib-0.37.0.dist-info}/LICENSE +0 -0
- {tracktolib-0.36.0.dist-info → tracktolib-0.37.0.dist-info}/WHEEL +0 -0
tracktolib/pg/utils.py
CHANGED
|
@@ -3,7 +3,7 @@ import datetime as dt
|
|
|
3
3
|
import functools
|
|
4
4
|
import logging
|
|
5
5
|
from pathlib import Path
|
|
6
|
-
from typing import AsyncIterator,
|
|
6
|
+
from typing import AsyncIterator, Iterable, Sequence
|
|
7
7
|
from typing_extensions import LiteralString
|
|
8
8
|
from ..pg_utils import get_conflict_query
|
|
9
9
|
|
|
@@ -91,7 +91,10 @@ async def upsert_csv(conn: asyncpg.Connection,
|
|
|
91
91
|
chunk_size: int = 5_000,
|
|
92
92
|
show_progress: bool = False,
|
|
93
93
|
nb_lines: int | None = None,
|
|
94
|
-
on_conflict_keys: Iterable[LiteralString] | None = None
|
|
94
|
+
on_conflict_keys: Iterable[LiteralString] | None = None,
|
|
95
|
+
delimiter: str = ',',
|
|
96
|
+
col_names: Sequence[str] | None = None,
|
|
97
|
+
skip_header: bool = False):
|
|
95
98
|
infos = await get_table_infos(conn, schema, table)
|
|
96
99
|
|
|
97
100
|
on_conflict_str = 'ON CONFLICT DO NOTHING'
|
|
@@ -100,8 +103,10 @@ async def upsert_csv(conn: asyncpg.Connection,
|
|
|
100
103
|
update_keys=on_conflict_keys)
|
|
101
104
|
|
|
102
105
|
with csv_path.open('r') as f:
|
|
103
|
-
reader = csv.DictReader(f)
|
|
104
|
-
|
|
106
|
+
reader = csv.DictReader(f, delimiter=delimiter, fieldnames=col_names)
|
|
107
|
+
if skip_header:
|
|
108
|
+
next(reader)
|
|
109
|
+
_columns = col_names if col_names else [x.lower() for x in (reader.fieldnames or [])]
|
|
105
110
|
async with conn.transaction():
|
|
106
111
|
_tmp_table, _tmp_query, _insert_query = get_tmp_table_query(schema, table,
|
|
107
112
|
columns=infos.keys(),
|
|
@@ -5,7 +5,7 @@ tracktolib/http.py,sha256=GHWvD9rHTF1oAnG6Ptna_oeMDcwCxYYpPxLOME-oZ3Y,1574
|
|
|
5
5
|
tracktolib/logs.py,sha256=nbI9LO2NaXDAv9aoUkad54V_x8B8zga-MwqUfYb-pkk,2523
|
|
6
6
|
tracktolib/pg/__init__.py,sha256=mK_EAUN9wTLQC38n3iaBFTP2YzaEo7S17AyFiKHgu6k,241
|
|
7
7
|
tracktolib/pg/query.py,sha256=E42F2pq_kv465XO2HQo52BhKhORsZ-mdvsGsqKdnbVg,14969
|
|
8
|
-
tracktolib/pg/utils.py,sha256=
|
|
8
|
+
tracktolib/pg/utils.py,sha256=Yfd-6G5KfHbwIReYrymzdozFs8flQaP-R9K5CP42t_4,5059
|
|
9
9
|
tracktolib/pg_sync.py,sha256=M_9DMVXWozhxD8KGVWKxLblOG4K-npbK5SKoO-Rz0yM,5203
|
|
10
10
|
tracktolib/pg_utils.py,sha256=e5QdJ5clFtap949U57sSjplaWi6LNv-Rs2cuz4NRIxk,2012
|
|
11
11
|
tracktolib/s3/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -13,7 +13,7 @@ tracktolib/s3/minio.py,sha256=gkpI2bvVwfXaAFY7M9e0Mlv82x0PjuriS8LdRmEJtMo,1258
|
|
|
13
13
|
tracktolib/s3/s3.py,sha256=Kfmz0uLl5yGQxH4XvAfIe1yhOieTXS9Ck85nhj_aMnQ,4011
|
|
14
14
|
tracktolib/tests.py,sha256=GycCVRUOdzazxqBXKBWWzhrlkV8yyD7NaActz_A2WXU,590
|
|
15
15
|
tracktolib/utils.py,sha256=kU35LCJaFDNg0IR9ekAi4uEJ3unZCC3VPzqgkctt06Q,5437
|
|
16
|
-
tracktolib-0.
|
|
17
|
-
tracktolib-0.
|
|
18
|
-
tracktolib-0.
|
|
19
|
-
tracktolib-0.
|
|
16
|
+
tracktolib-0.37.0.dist-info/LICENSE,sha256=uUanH0X7SeZEPdsRTHegMSMTiIHMurt9H0jSwEwKE1Y,1081
|
|
17
|
+
tracktolib-0.37.0.dist-info/WHEEL,sha256=vxFmldFsRN_Hx10GDvsdv1wroKq8r5Lzvjp6GZ4OO8c,88
|
|
18
|
+
tracktolib-0.37.0.dist-info/METADATA,sha256=Fu_O-M1gdC3VCihdzJN3PVTRx9VjkO5TacWTLfNQC4c,3630
|
|
19
|
+
tracktolib-0.37.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|