sql-blocks 1.25.32011301__py3-none-any.whl → 1.25.33022122__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.
sql_blocks/sql_blocks.py CHANGED
@@ -1504,6 +1504,17 @@ class CTE(Select):
1504
1504
  justify(q) for q in self.query_list
1505
1505
  ), super().__str__()
1506
1506
  )
1507
+ def join(self, pattern: str, fields: list | str, format: str):
1508
+ if isinstance(fields, str):
1509
+ count = len( fields.split(',') )
1510
+ else:
1511
+ count = len(fields)
1512
+ queries = detect(
1513
+ pattern*count, join_queries=False, format=format
1514
+ )
1515
+ FieldList(fields, queries, ziped=True).add('', self)
1516
+ self.break_lines = True
1517
+ return self
1507
1518
 
1508
1519
  class Recursive(CTE):
1509
1520
  prefix = 'RECURSIVE '
@@ -1535,23 +1546,13 @@ class Recursive(CTE):
1535
1546
  Where.formula(formula).add(foreign_key or pk_field, t2)
1536
1547
  return cls(name, [t1, t2])
1537
1548
 
1538
- def join(self, pattern: str, fields: list | str, format: str):
1539
- if isinstance(fields, str):
1540
- count = len( fields.split(',') )
1541
- else:
1542
- count = len(fields)
1543
- queries = detect(
1544
- pattern*count, join_queries=False, format=format
1545
- )
1546
- FieldList(fields, queries, ziped=True).add('', self)
1547
- self.break_lines = True
1548
-
1549
1549
  def counter(self, name: str, start, increment: str='+1'):
1550
1550
  for i, query in enumerate(self.query_list):
1551
1551
  if i == 0:
1552
1552
  Field.add(f'{start} AS {name}', query)
1553
1553
  else:
1554
1554
  Field.add(f'({name}{increment}) AS {name}', query)
1555
+ return self
1555
1556
 
1556
1557
 
1557
1558
  # ----- Rules -----
@@ -1697,3 +1698,16 @@ def detect(text: str, join_queries: bool = True, format: str='') -> Select | lis
1697
1698
  return result
1698
1699
 
1699
1700
 
1701
+ if __name__ == "__main__":
1702
+ FLIGHT_FIELDS = 'departure, arrival'
1703
+ R = Recursive.create(
1704
+ 'Route R', f'Flyght({FLIGHT_FIELDS})',
1705
+ '[2] = R.[1]', 'JFK', '.csv'
1706
+ ).join(
1707
+ 'Airport(*id,name)', FLIGHT_FIELDS, format='.parquet'
1708
+ ).counter(
1709
+ 'stops', 0
1710
+ )
1711
+ print(R)
1712
+ print('-'*50)
1713
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sql_blocks
3
- Version: 1.25.32011301
3
+ Version: 1.25.33022122
4
4
  Summary: Allows you to create objects for parts of SQL query commands. Also to combine these objects by joining them, adding or removing parts...
5
5
  Home-page: https://github.com/julio-cascalles/sql_blocks
6
6
  Author: Júlio Cascalles
@@ -0,0 +1,7 @@
1
+ sql_blocks/__init__.py,sha256=5ItzGCyqqa6kwY8wvF9kapyHsAiWJ7KEXCcC-OtdXKg,37
2
+ sql_blocks/sql_blocks.py,sha256=Dup1dUwejLXPa694JpegI3Ky6UnEOsxg_FOClP26qdI,57352
3
+ sql_blocks-1.25.33022122.dist-info/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
4
+ sql_blocks-1.25.33022122.dist-info/METADATA,sha256=AknkUf3x_w302D2UiTCCwhMkCOgoP-tQ5HKjsS2pjYE,19574
5
+ sql_blocks-1.25.33022122.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
6
+ sql_blocks-1.25.33022122.dist-info/top_level.txt,sha256=57AbUvUjYNy4m1EqDaU3WHeP-uyIAfV0n8GAUp1a1YQ,11
7
+ sql_blocks-1.25.33022122.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- sql_blocks/__init__.py,sha256=5ItzGCyqqa6kwY8wvF9kapyHsAiWJ7KEXCcC-OtdXKg,37
2
- sql_blocks/sql_blocks.py,sha256=VW8n2nWu7RREnns8dmYruhlvzGBCA3EeuBKiXCjClmE,56975
3
- sql_blocks-1.25.32011301.dist-info/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
4
- sql_blocks-1.25.32011301.dist-info/METADATA,sha256=g_Yr5mTcquKqG5PM6qSNeWsuZ4wbo88pdZUldp_rt9k,19574
5
- sql_blocks-1.25.32011301.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
6
- sql_blocks-1.25.32011301.dist-info/top_level.txt,sha256=57AbUvUjYNy4m1EqDaU3WHeP-uyIAfV0n8GAUp1a1YQ,11
7
- sql_blocks-1.25.32011301.dist-info/RECORD,,