ingestr 0.13.51__py3-none-any.whl → 0.13.52__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.

Potentially problematic release.


This version of ingestr might be problematic. Click here for more details.

ingestr/main.py CHANGED
@@ -58,6 +58,7 @@ class LoaderFileFormat(str, Enum):
58
58
 
59
59
 
60
60
  class SqlBackend(str, Enum):
61
+ default = "default"
61
62
  sqlalchemy = "sqlalchemy"
62
63
  pyarrow = "pyarrow"
63
64
  connectorx = "connectorx"
@@ -187,7 +188,7 @@ def ingest(
187
188
  help="The SQL backend to use",
188
189
  envvar=["SQL_BACKEND", "INGESTR_SQL_BACKEND"],
189
190
  ),
190
- ] = SqlBackend.pyarrow, # type: ignore
191
+ ] = SqlBackend.default, # type: ignore
191
192
  loader_file_format: Annotated[
192
193
  Optional[LoaderFileFormat],
193
194
  typer.Option(
@@ -289,7 +290,11 @@ def ingest(
289
290
  from ingestr.src.collector.spinner import SpinnerCollector
290
291
  from ingestr.src.destinations import AthenaDestination
291
292
  from ingestr.src.factory import SourceDestinationFactory
292
- from ingestr.src.filters import cast_set_to_list, handle_mysql_empty_dates
293
+ from ingestr.src.filters import (
294
+ cast_set_to_list,
295
+ cast_spanner_types,
296
+ handle_mysql_empty_dates,
297
+ )
293
298
  from ingestr.src.sources import MongoDbSource
294
299
 
295
300
  def report_errors(run_info: LoadInfo):
@@ -517,6 +522,15 @@ def ingest(
517
522
  if interval_end:
518
523
  interval_end = interval_end.date() # type: ignore
519
524
 
525
+ if factory.source_scheme.startswith("spanner"):
526
+ # we tend to use the 'pyarrow' backend in general, however, it has issues with JSON objects, so we override it to 'sqlalchemy' for Spanner.
527
+ if sql_backend.value == SqlBackend.default:
528
+ sql_backend = SqlBackend.sqlalchemy
529
+
530
+ # this allows us to identify the cases where the user does not have a preference, so that for some sources we can override it.
531
+ if sql_backend == SqlBackend.default:
532
+ sql_backend = SqlBackend.pyarrow
533
+
520
534
  dlt_source = source.dlt_source(
521
535
  uri=source_uri,
522
536
  table=source_table,
@@ -535,6 +549,9 @@ def ingest(
535
549
  if factory.source_scheme.startswith("mysql"):
536
550
  resource.for_each(dlt_source, lambda x: x.add_map(handle_mysql_empty_dates))
537
551
 
552
+ if factory.source_scheme.startswith("spanner"):
553
+ resource.for_each(dlt_source, lambda x: x.add_map(cast_spanner_types))
554
+
538
555
  if yield_limit:
539
556
  resource.for_each(dlt_source, lambda x: x.add_limit(yield_limit))
540
557
 
ingestr/src/buildinfo.py CHANGED
@@ -1 +1 @@
1
- version = "v0.13.51"
1
+ version = "v0.13.52"
@@ -468,3 +468,15 @@ class S3Destination:
468
468
 
469
469
  def post_load(self) -> None:
470
470
  pass
471
+
472
+
473
+ class SqliteDestination(GenericSqlDestination):
474
+ def dlt_dest(self, uri: str, **kwargs):
475
+ return dlt.destinations.sqlalchemy(credentials=uri)
476
+
477
+ def dlt_run_params(self, uri: str, table: str, **kwargs):
478
+ return {
479
+ #https://dlthub.com/docs/dlt-ecosystem/destinations/sqlalchemy#dataset-files
480
+ "dataset_name": "main",
481
+ "table_name": table,
482
+ }
ingestr/src/factory.py CHANGED
@@ -15,6 +15,7 @@ from ingestr.src.destinations import (
15
15
  RedshiftDestination,
16
16
  S3Destination,
17
17
  SnowflakeDestination,
18
+ SqliteDestination,
18
19
  SynapseDestination,
19
20
  )
20
21
  from ingestr.src.sources import (
@@ -54,12 +55,12 @@ from ingestr.src.sources import (
54
55
  SalesforceSource,
55
56
  ShopifySource,
56
57
  SlackSource,
58
+ SmartsheetSource,
57
59
  SolidgateSource,
58
60
  SqlSource,
59
61
  StripeAnalyticsSource,
60
62
  TikTokSource,
61
63
  ZendeskSource,
62
- SmartsheetSource,
63
64
  )
64
65
 
65
66
  SQL_SOURCE_SCHEMES = [
@@ -182,6 +183,7 @@ class SourceDestinationFactory:
182
183
  "clickhouse+native": ClickhouseDestination,
183
184
  "clickhouse": ClickhouseDestination,
184
185
  "s3": S3Destination,
186
+ "sqlite": SqliteDestination,
185
187
  }
186
188
 
187
189
  def __init__(self, source_uri: str, destination_uri: str):
ingestr/src/filters.py CHANGED
@@ -7,6 +7,20 @@ def cast_set_to_list(row):
7
7
  return row
8
8
 
9
9
 
10
+ def cast_spanner_types(row):
11
+ if not isinstance(row, dict):
12
+ return row
13
+
14
+ from google.cloud.spanner_v1.data_types import JsonObject
15
+
16
+ for key in row.keys():
17
+ if isinstance(row[key], JsonObject):
18
+ import json
19
+
20
+ row[key] = json.loads(row[key].serialize())
21
+ return row
22
+
23
+
10
24
  def handle_mysql_empty_dates(row):
11
25
  # MySQL returns empty dates as 0000-00-00, which is not a valid date, we handle them here.
12
26
  if not isinstance(row, dict):
@@ -43,7 +43,7 @@ def solidgate_source(
43
43
  yield solidgate_client.fetch_data(path, date_from=start_dt, date_to=end_dt)
44
44
 
45
45
  @dlt.resource(
46
- name="apm-orders",
46
+ name="apm_orders",
47
47
  write_disposition="merge",
48
48
  primary_key="order_id",
49
49
  columns={
@@ -69,7 +69,7 @@ def solidgate_source(
69
69
  yield solidgate_client.fetch_data(path, date_from=start_dt, date_to=end_dt)
70
70
 
71
71
  @dlt.resource(
72
- name="card-orders",
72
+ name="card_orders",
73
73
  write_disposition="merge",
74
74
  primary_key="order_id",
75
75
  columns={
@@ -95,7 +95,7 @@ def solidgate_source(
95
95
  yield solidgate_client.fetch_data(path, date_from=start_dt, date_to=end_dt)
96
96
 
97
97
  @dlt.resource(
98
- name="financial-entries",
98
+ name="financial_entries",
99
99
  write_disposition="merge",
100
100
  primary_key="id",
101
101
  columns={
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ingestr
3
- Version: 0.13.51
3
+ Version: 0.13.52
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,12 +1,12 @@
1
1
  ingestr/conftest.py,sha256=Q03FIJIZpLBbpj55cfCHIKEjc1FCvWJhMF2cidUJKQU,1748
2
- ingestr/main.py,sha256=rHxHQAbd0ccW2e2kQSWlv7-5qcc2ZB6Eh3vyjm4Nzns,25550
2
+ ingestr/main.py,sha256=GkC1hdq8AVGrvolc95zMfjmibI95p2pmFkbgCOVf-Og,26311
3
3
  ingestr/src/.gitignore,sha256=8cX1AZTSI0TcdZFGTmS_oyBjpfCzhOEt0DdAo2dFIY8,203
4
4
  ingestr/src/blob.py,sha256=onMe5ZHxPXTdcB_s2oGNdMo-XQJ3ajwOsWE9eSTGFmc,1495
5
- ingestr/src/buildinfo.py,sha256=ZgugQZPIlr-_7kRH5qIupQ5e48JTOHSlRWEsmNx4wXw,21
6
- ingestr/src/destinations.py,sha256=41Bj1UgxR8a2KcZWqtGw74AKZKnSBrueQRnBdrf3c-A,16003
5
+ ingestr/src/buildinfo.py,sha256=qcKqSPI861BBapk7rbcYkc9M_18QQnT44YM1Zr_Sg80,21
6
+ ingestr/src/destinations.py,sha256=axSm0GLM_bKQmWYb74fnHebNktWgtfAyyqdHV-zBOsA,16405
7
7
  ingestr/src/errors.py,sha256=Ufs4_DfE77_E3vnA1fOQdi6cmuLVNm7_SbFLkL1XPGk,686
8
- ingestr/src/factory.py,sha256=JeK0M8C05-_KxxIhtevs-MJGLlngXUQupd-Pm4Fg904,5803
9
- ingestr/src/filters.py,sha256=C-_TIVkF_cxZBgG-Run2Oyn0TAhJgA8IWXZ-OPY3uek,1136
8
+ ingestr/src/factory.py,sha256=5yrg-XkaixuCkiTz3B7mraE8LaANXtzItenbx8TdPrE,5863
9
+ ingestr/src/filters.py,sha256=LLecXe9QkLFkFLUZ92OXNdcANr1a8edDxrflc2ko_KA,1452
10
10
  ingestr/src/http_client.py,sha256=bxqsk6nJNXCo-79gW04B53DQO-yr25vaSsqP0AKtjx4,732
11
11
  ingestr/src/loader.py,sha256=9NaWAyfkXdqAZSS-N72Iwo36Lbx4PyqIfaaH1dNdkFs,1712
12
12
  ingestr/src/partition.py,sha256=BrIP6wFJvyR7Nus_3ElnfxknUXeCipK_E_bB8kZowfc,969
@@ -109,7 +109,7 @@ ingestr/src/slack/__init__.py,sha256=pyDukxcilqTAe_bBzfWJ8Vxi83S-XEdEFBH2pEgILrM
109
109
  ingestr/src/slack/helpers.py,sha256=08TLK7vhFvH_uekdLVOLF3bTDe1zgH0QxHObXHzk1a8,6545
110
110
  ingestr/src/slack/settings.py,sha256=NhKn4y1zokEa5EmIZ05wtj_-I0GOASXZ5V81M1zXCtY,457
111
111
  ingestr/src/smartsheets/__init__.py,sha256=pdzSV7rA0XYD5Xa1u4zb6vziy5iFXIQNROkpJ9oYas0,1623
112
- ingestr/src/solidgate/__init__.py,sha256=DZYQ4M3Cc7AIbdQcNQm_6yX2whnFhE-iM10-ACJ3W3A,3626
112
+ ingestr/src/solidgate/__init__.py,sha256=JdaXvAu5QGuf9-FY294vwCQCEmfrqIld9oqbzqCJS3g,3626
113
113
  ingestr/src/solidgate/helpers.py,sha256=oePEc9nnvmN3IaKrfJCvyKL79xdGM0-gRTN3-8tY4Fc,4952
114
114
  ingestr/src/sql_database/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
115
115
  ingestr/src/sql_database/callbacks.py,sha256=sEFFmXxAURY3yeBjnawigDtq9LBCvi8HFqG4kLd7tMU,2002
@@ -135,8 +135,8 @@ ingestr/testdata/merge_expected.csv,sha256=DReHqWGnQMsf2PBv_Q2pfjsgvikYFnf1zYcQZ
135
135
  ingestr/testdata/merge_part1.csv,sha256=Pw8Z9IDKcNU0qQHx1z6BUf4rF_-SxKGFOvymCt4OY9I,185
136
136
  ingestr/testdata/merge_part2.csv,sha256=T_GiWxA81SN63_tMOIuemcvboEFeAmbKc7xRXvL9esw,287
137
137
  ingestr/tests/unit/test_smartsheets.py,sha256=eiC2CCO4iNJcuN36ONvqmEDryCA1bA1REpayHpu42lk,5058
138
- ingestr-0.13.51.dist-info/METADATA,sha256=danPRyBhqlvyOwtw8kBmBh5FEY_xH6upsy5GrsFaMg4,13983
139
- ingestr-0.13.51.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
140
- ingestr-0.13.51.dist-info/entry_points.txt,sha256=oPJy0KBnPWYjDtP1k8qwAihcTLHSZokSQvRAw_wtfJM,46
141
- ingestr-0.13.51.dist-info/licenses/LICENSE.md,sha256=cW8wIhn8HFE-KLStDF9jHQ1O_ARWP3kTpk_-eOccL24,1075
142
- ingestr-0.13.51.dist-info/RECORD,,
138
+ ingestr-0.13.52.dist-info/METADATA,sha256=jfSWJ6mE6vPz-5XsIIjqdLxd45-OrOUKbhbwJqiZlSc,13983
139
+ ingestr-0.13.52.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
140
+ ingestr-0.13.52.dist-info/entry_points.txt,sha256=oPJy0KBnPWYjDtP1k8qwAihcTLHSZokSQvRAw_wtfJM,46
141
+ ingestr-0.13.52.dist-info/licenses/LICENSE.md,sha256=cW8wIhn8HFE-KLStDF9jHQ1O_ARWP3kTpk_-eOccL24,1075
142
+ ingestr-0.13.52.dist-info/RECORD,,