ingestr 0.13.0__py3-none-any.whl → 0.13.2__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.
@@ -1,6 +1,5 @@
1
1
  import base64
2
2
  import csv
3
- import gzip
4
3
  import json
5
4
  import os
6
5
  import shutil
@@ -8,6 +7,7 @@ import tempfile
8
7
  from urllib.parse import parse_qs, quote, urlparse
9
8
 
10
9
  import dlt
10
+ import pyarrow.parquet # type: ignore
11
11
  from dlt.common.configuration.specs import AwsCredentials
12
12
  from dlt.destinations.impl.clickhouse.configuration import (
13
13
  ClickHouseCredentials,
@@ -184,19 +184,17 @@ class CsvDestination(GenericSqlDestination):
184
184
  if output_path.count("/") > 1:
185
185
  os.makedirs(os.path.dirname(output_path), exist_ok=True)
186
186
 
187
- with gzip.open(first_file_path, "rt", encoding="utf-8") as jsonl_file: # type: ignore
188
- with open(output_path, "w", newline="") as csv_file:
189
- csv_writer = None
190
- for line in jsonl_file:
191
- json_obj = filter_keys(json.loads(line))
192
- if csv_writer is None:
193
- csv_writer = csv.DictWriter(
194
- csv_file, fieldnames=json_obj.keys()
195
- )
196
- csv_writer.writeheader()
197
-
198
- csv_writer.writerow(json_obj)
199
-
187
+ table = pyarrow.parquet.read_table(first_file_path)
188
+ rows = table.to_pylist()
189
+ with open(output_path, "w", newline="") as csv_file:
190
+ csv_writer = None
191
+ for row in rows:
192
+ row = filter_keys(row)
193
+ if csv_writer is None:
194
+ csv_writer = csv.DictWriter(csv_file, fieldnames=row.keys())
195
+ csv_writer.writeheader()
196
+
197
+ csv_writer.writerow(row)
200
198
  shutil.rmtree(self.temp_path)
201
199
 
202
200
 
@@ -299,12 +297,21 @@ class ClickhouseDestination:
299
297
  raise ValueError(
300
298
  "The TCP port of the ClickHouse server is required to establish a connection."
301
299
  )
302
-
300
+
303
301
  query_params = parse_qs(parsed_uri.query)
302
+ secure = int(query_params["secure"][0]) if "secure" in query_params else 1
303
+
304
304
  http_port = (
305
- int(query_params["http_port"][0]) if "http_port" in query_params else 8123
305
+ int(query_params["http_port"][0])
306
+ if "http_port" in query_params
307
+ else 8443 if secure == 1 else 8123
306
308
  )
307
309
 
310
+ if secure not in (0, 1):
311
+ raise ValueError(
312
+ "Invalid value for secure. Set to `1` for a secure HTTPS connection or `0` for a non-secure HTTP connection."
313
+ )
314
+
308
315
  credentials = ClickHouseCredentials(
309
316
  {
310
317
  "host": host,
@@ -313,10 +320,9 @@ class ClickhouseDestination:
313
320
  "password": password,
314
321
  "database": database,
315
322
  "http_port": http_port,
316
- "secure": 0,
323
+ "secure": secure,
317
324
  }
318
325
  )
319
-
320
326
  return dlt.destinations.clickhouse(credentials=credentials)
321
327
 
322
328
  def dlt_run_params(self, uri: str, table: str, **kwargs) -> dict:
ingestr/src/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.13.0"
1
+ __version__ = "0.13.2"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ingestr
3
- Version: 0.13.0
3
+ Version: 0.13.2
4
4
  Summary: ingestr is a command-line application that ingests data from various sources and stores them in any database.
5
5
  Project-URL: Homepage, https://github.com/bruin-data/ingestr
6
6
  Project-URL: Issues, https://github.com/bruin-data/ingestr/issues
@@ -1,14 +1,14 @@
1
1
  ingestr/main.py,sha256=ufn8AcM2ID80ChUApJzYDjnQaurMXOkYfTm6GzAggSQ,24746
2
2
  ingestr/src/.gitignore,sha256=8cX1AZTSI0TcdZFGTmS_oyBjpfCzhOEt0DdAo2dFIY8,203
3
3
  ingestr/src/blob.py,sha256=XDk_XqmU_He4sQ1brY3ceoZgpq_ZBZihz1gHW9MzqUk,1381
4
- ingestr/src/destinations.py,sha256=Lz7exgnfO1xW2l9Szkc5V7Pw6CcVQfIejkPCd0GSm2s,10926
4
+ ingestr/src/destinations.py,sha256=aMRlgsq5ANnpSQmGqqWY8diB8DsF_WHbb667GnJ56js,11178
5
5
  ingestr/src/errors.py,sha256=Ufs4_DfE77_E3vnA1fOQdi6cmuLVNm7_SbFLkL1XPGk,686
6
6
  ingestr/src/factory.py,sha256=3XM2rilA69vkkOCHNzUt1XqCOc3gLMnOnlQmW5d1V5s,4870
7
7
  ingestr/src/filters.py,sha256=0JQXeAr2APFMnW2sd-6BlAMWv93bXV17j8b5MM8sHmM,580
8
8
  ingestr/src/sources.py,sha256=VBuD6ngMHKaCLeYZ9Oe9tw67578hPc1dP_5iBNtEJdM,61683
9
9
  ingestr/src/table_definition.py,sha256=REbAbqdlmUMUuRh8nEQRreWjPVOQ5ZcfqGkScKdCrmk,390
10
10
  ingestr/src/time.py,sha256=H_Fk2J4ShXyUM-EMY7MqCLZQhlnZMZvO952bmZPc4yE,254
11
- ingestr/src/version.py,sha256=DgpLNbv0e1LIEOOe54Db8_390i9pelMEFEnsBsNmyhA,23
11
+ ingestr/src/version.py,sha256=blu6md2c3Nnj5gDBi8U36sYO3k8HcND8s7UoQBjfn3g,23
12
12
  ingestr/src/adjust/__init__.py,sha256=ULjtJqrNS6XDvUyGl0tjl12-tLyXlCgeFe2icTbtu3Q,3255
13
13
  ingestr/src/adjust/adjust_helpers.py,sha256=av97NPSn-hQtTbAC0vUSCAWYePmOiG5R-DGdMssm7FQ,3646
14
14
  ingestr/src/airtable/__init__.py,sha256=GHWYrjI2qhs_JihdNJysB0Ni3bzqT_MLXn_S9_Q5zRA,2775
@@ -100,8 +100,8 @@ ingestr/testdata/delete_insert_part2.csv,sha256=B_KUzpzbNdDY_n7wWop1mT2cz36TmayS
100
100
  ingestr/testdata/merge_expected.csv,sha256=DReHqWGnQMsf2PBv_Q2pfjsgvikYFnf1zYcQZ7ZqYN0,276
101
101
  ingestr/testdata/merge_part1.csv,sha256=Pw8Z9IDKcNU0qQHx1z6BUf4rF_-SxKGFOvymCt4OY9I,185
102
102
  ingestr/testdata/merge_part2.csv,sha256=T_GiWxA81SN63_tMOIuemcvboEFeAmbKc7xRXvL9esw,287
103
- ingestr-0.13.0.dist-info/METADATA,sha256=o95nmTeSSzxMzMs42F9fz9WN-MuJ8DE4QHGfL6fQlHU,8252
104
- ingestr-0.13.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
105
- ingestr-0.13.0.dist-info/entry_points.txt,sha256=oPJy0KBnPWYjDtP1k8qwAihcTLHSZokSQvRAw_wtfJM,46
106
- ingestr-0.13.0.dist-info/licenses/LICENSE.md,sha256=cW8wIhn8HFE-KLStDF9jHQ1O_ARWP3kTpk_-eOccL24,1075
107
- ingestr-0.13.0.dist-info/RECORD,,
103
+ ingestr-0.13.2.dist-info/METADATA,sha256=ivVRv68P1AR_inmOV4_yMW8tfTnTtE7EBnA-bKDiIL4,8252
104
+ ingestr-0.13.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
105
+ ingestr-0.13.2.dist-info/entry_points.txt,sha256=oPJy0KBnPWYjDtP1k8qwAihcTLHSZokSQvRAw_wtfJM,46
106
+ ingestr-0.13.2.dist-info/licenses/LICENSE.md,sha256=cW8wIhn8HFE-KLStDF9jHQ1O_ARWP3kTpk_-eOccL24,1075
107
+ ingestr-0.13.2.dist-info/RECORD,,