singlestoredb 1.4.1__cp38-abi3-win32.whl → 1.4.3__cp38-abi3-win32.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 singlestoredb might be problematic. Click here for more details.

_singlestoredb_accel.pyd CHANGED
Binary file
singlestoredb/__init__.py CHANGED
@@ -13,7 +13,7 @@ Examples
13
13
 
14
14
  """
15
15
 
16
- __version__ = '1.4.1'
16
+ __version__ = '1.4.3'
17
17
 
18
18
  from typing import Any
19
19
 
@@ -28,8 +28,23 @@ CORE_GRAMMAR = r'''
28
28
  eq = ws* "=" ws*
29
29
  open_paren = ws* "(" ws*
30
30
  close_paren = ws* ")" ws*
31
+ open_repeats = ws* ~r"[\(\[\{]" ws*
32
+ close_repeats = ws* ~r"[\)\]\}]" ws*
31
33
  select = ~r"SELECT"i ws+ ~r".+" ws*
32
- '''
34
+
35
+ json = ws* json_object ws*
36
+ json_object = ~r"{\s*" json_members? ~r"\s*}"
37
+ json_members = json_mapping (~r"\s*,\s*" json_mapping)*
38
+ json_mapping = json_string ~r"\s*:\s*" json_value
39
+ json_array = ~r"\[\s*" json_items? ~r"\s*\]"
40
+ json_items = json_value (~r"\s*,\s*" json_value)*
41
+ json_value = json_object / json_array / json_string / json_true_val / json_false_val / json_null_val / json_number
42
+ json_true_val = "true"
43
+ json_false_val = "false"
44
+ json_null_val = "null"
45
+ json_string = ~r"\"[ !#-\[\]-\U0010ffff]*(?:\\(?:[\"\\/bfnrt]|u[0-9A-Fa-f]{4})[ !#-\[\]-\U0010ffff]*)*\""
46
+ json_number = ~r"-?(0|[1-9][0-9]*)(\.\d*)?([eE][-+]?\d+)?"
47
+ ''' # noqa: E501
33
48
 
34
49
  BUILTINS = {
35
50
  '<order-by>': r'''
@@ -47,6 +62,7 @@ BUILTINS = {
47
62
  ''',
48
63
  '<integer>': '',
49
64
  '<number>': '',
65
+ '<json>': '',
50
66
  }
51
67
 
52
68
  BUILTIN_DEFAULTS = { # type: ignore
@@ -54,9 +70,36 @@ BUILTIN_DEFAULTS = { # type: ignore
54
70
  'like': None,
55
71
  'extended': False,
56
72
  'limit': None,
73
+ 'json': {},
74
+ }
75
+
76
+ _json_unesc_re = re.compile(r'\\(["/\\bfnrt]|u[0-9A-Fa-f])')
77
+ _json_unesc_map = {
78
+ '"': '"',
79
+ '/': '/',
80
+ '\\': '\\',
81
+ 'b': '\b',
82
+ 'f': '\f',
83
+ 'n': '\n',
84
+ 'r': '\r',
85
+ 't': '\t',
57
86
  }
58
87
 
59
88
 
89
+ def _json_unescape(m: Any) -> str:
90
+ c = m.group(1)
91
+ if c[0] == 'u':
92
+ return chr(int(c[1:], 16))
93
+ c2 = _json_unesc_map.get(c)
94
+ if not c2:
95
+ raise ValueError(f'invalid escape sequence: {m.group(0)}')
96
+ return c2
97
+
98
+
99
+ def json_unescape(s: str) -> str:
100
+ return _json_unesc_re.sub(_json_unescape, s[1:-1])
101
+
102
+
60
103
  def get_keywords(grammar: str) -> Tuple[str, ...]:
61
104
  """Return all all-caps words from the beginning of the line."""
62
105
  m = re.match(r'^\s*((?:[A-Z0-9_]+)(\s+|$|;))+', grammar)
@@ -89,7 +132,7 @@ def process_alternates(m: Any) -> str:
89
132
  def process_repeats(m: Any) -> str:
90
133
  """Add repeated patterns."""
91
134
  sql = m.group(1).strip()
92
- return f'open_paren? {sql} ws* ( comma {sql} ws* )* close_paren?'
135
+ return f'open_repeats? {sql} ws* ( comma {sql} ws* )* close_repeats?'
93
136
 
94
137
 
95
138
  def lower_and_regex(m: Any) -> str:
@@ -639,6 +682,14 @@ class SQLHandler(NodeVisitor):
639
682
  """Close parenthesis."""
640
683
  return
641
684
 
685
+ def visit_open_repeats(self, node: Node, visited_children: Iterable[Any]) -> Any:
686
+ """Open repeat grouping."""
687
+ return
688
+
689
+ def visit_close_repeats(self, node: Node, visited_children: Iterable[Any]) -> Any:
690
+ """Close repeat grouping."""
691
+ return
692
+
642
693
  def visit_init(self, node: Node, visited_children: Iterable[Any]) -> Any:
643
694
  """Entry point of the grammar."""
644
695
  _, out, *_ = visited_children
@@ -662,6 +713,57 @@ class SQLHandler(NodeVisitor):
662
713
  ascending.append(value[1].upper().startswith('A'))
663
714
  return {'order_by': {'by': by, 'ascending': ascending}}
664
715
 
716
+ def _delimited(self, node: Node, children: Iterable[Any]) -> Any:
717
+ children = list(children)
718
+ items = [children[0]]
719
+ items.extend(item for _, item in children[1])
720
+ return items
721
+
722
+ def _atomic(self, node: Node, children: Iterable[Any]) -> Any:
723
+ return list(children)[0]
724
+
725
+ # visitors
726
+ visit_json_value = _atomic
727
+ visit_json_members = visit_json_items = _delimited
728
+
729
+ def visit_json_object(self, node: Node, children: Iterable[Any]) -> Any:
730
+ _, members, _ = children
731
+ if isinstance(members, list):
732
+ members = members[0]
733
+ else:
734
+ members = []
735
+ members = [x for x in members if x != '']
736
+ return dict(members)
737
+
738
+ def visit_json_array(self, node: Node, children: Iterable[Any]) -> Any:
739
+ _, values, _ = children
740
+ if isinstance(values, list):
741
+ values = values[0]
742
+ else:
743
+ values = []
744
+ return values
745
+
746
+ def visit_json_mapping(self, node: Node, children: Iterable[Any]) -> Any:
747
+ key, _, value = children
748
+ return key, value
749
+
750
+ def visit_json_string(self, node: Node, children: Iterable[Any]) -> Any:
751
+ return json_unescape(node.text)
752
+
753
+ def visit_json_number(self, node: Node, children: Iterable[Any]) -> Any:
754
+ if '.' in node.text:
755
+ return float(node.text)
756
+ return int(node.text)
757
+
758
+ def visit_json_true_val(self, node: Node, children: Iterable[Any]) -> Any:
759
+ return True
760
+
761
+ def visit_json_false_val(self, node: Node, children: Iterable[Any]) -> Any:
762
+ return False
763
+
764
+ def visit_json_null_val(self, node: Node, children: Iterable[Any]) -> Any:
765
+ return None
766
+
665
767
  def generic_visit(self, node: Node, visited_children: Iterable[Any]) -> Any:
666
768
  """
667
769
  Handle all undefined rules.
@@ -675,6 +777,9 @@ class SQLHandler(NodeVisitor):
675
777
  rule can have repeated values, a list of values is returned.
676
778
 
677
779
  """
780
+ if node.expr_name.startswith('json'):
781
+ return visited_children or node.text
782
+
678
783
  # Call a grammar rule
679
784
  if node.expr_name in type(self).rule_info:
680
785
  n_keywords = type(self).rule_info[node.expr_name]['n_keywords']
@@ -123,14 +123,14 @@ class NamedList(List[T]):
123
123
  def _setup_authentication_info_handler() -> Callable[..., Dict[str, Any]]:
124
124
  """Setup authentication info event handler."""
125
125
 
126
- authentication_info: List[Tuple[str, Any]] = []
126
+ authentication_info: Dict[str, Any] = {}
127
127
 
128
128
  def handle_authentication_info(msg: Dict[str, Any]) -> None:
129
129
  """Handle authentication info events."""
130
130
  nonlocal authentication_info
131
131
  if msg.get('name', '') != 'singlestore.portal.authentication_updated':
132
132
  return
133
- authentication_info = list(msg.get('data', {}).items())
133
+ authentication_info = dict(msg.get('data', {}))
134
134
 
135
135
  events.subscribe(handle_authentication_info)
136
136
 
@@ -145,11 +145,27 @@ def _setup_authentication_info_handler() -> Callable[..., Dict[str, Any]]:
145
145
  out['user'] = data['user']
146
146
  if 'password' in data:
147
147
  out['password'] = data['password']
148
- authentication_info = list(out.items())
148
+ authentication_info = out
149
149
 
150
150
  events.subscribe(handle_authentication_info)
151
151
 
152
+ def retrieve_current_authentication_info() -> List[Tuple[str, Any]]:
153
+ """Retrieve JWT if not expired."""
154
+ nonlocal authentication_info
155
+ password = authentication_info.get('password')
156
+ if password:
157
+ expires = datetime.datetime.fromtimestamp(
158
+ jwt.decode(
159
+ password,
160
+ options={'verify_signature': False},
161
+ )['exp'],
162
+ )
163
+ if datetime.datetime.now() > expires:
164
+ authentication_info = {}
165
+ return list(authentication_info.items())
166
+
152
167
  def get_env() -> List[Tuple[str, Any]]:
168
+ """Retrieve JWT from environment."""
153
169
  conn = {}
154
170
  url = os.environ.get('SINGLESTOREDB_URL') or get_option('host')
155
171
  if url:
@@ -170,7 +186,7 @@ def _setup_authentication_info_handler() -> Callable[..., Dict[str, Any]]:
170
186
  return dict(
171
187
  itertools.chain(
172
188
  (get_env() if include_env else []),
173
- authentication_info,
189
+ retrieve_current_authentication_info(),
174
190
  ),
175
191
  )
176
192
 
@@ -182,7 +182,7 @@ class Portal(object):
182
182
  id = w.id
183
183
 
184
184
  self._call_javascript(
185
- 'changeWorkspace', [id],
185
+ 'changeDeployment', [id],
186
186
  wait_on_condition=lambda: self.workspace_id == id, # type: ignore
187
187
  timeout_message='timeout waiting for workspace update',
188
188
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: singlestoredb
3
- Version: 1.4.1
3
+ Version: 1.4.3
4
4
  Summary: Interface to the SingleStoreDB database and workspace management APIs
5
5
  Home-page: https://github.com/singlestore-labs/singlestoredb-python
6
6
  Author: SingleStore
@@ -1,5 +1,5 @@
1
- _singlestoredb_accel.pyd,sha256=4a9jkRxSS3bcpGAfN6Q24lKS3TvcELj3kfTKkx7A3pc,59904
2
- singlestoredb/__init__.py,sha256=KEqb2gHGKPyOxYZh-RhiXQ30pSKXzRKg-0m7pXMUPh8,1697
1
+ _singlestoredb_accel.pyd,sha256=JySQW9UIgy08VK7a0_0SsWZ6didExBbAyUUs4QIWxok,59904
2
+ singlestoredb/__init__.py,sha256=coTKAx_9TGFvUHphEf4cQk0Sd6wuK9ZrZuGjJmDVxw0,1697
3
3
  singlestoredb/auth.py,sha256=RmYiH0Wlc2RXc4pTlRMysxtBI445ggCIwojWKC_eDLE,7844
4
4
  singlestoredb/config.py,sha256=9pVmVEZ23NfJ3pokdBDA0cX3bwUz6SbuT4AZWAcIPR4,12235
5
5
  singlestoredb/connection.py,sha256=xdjf6HX-BS9BmwdjA3IlKeZx_e691_dVFMY3GvX_v64,46629
@@ -23,7 +23,7 @@ singlestoredb/functions/ext/rowdat_1.py,sha256=KYj_y5JWm3_B2-QC47HK-CNOrzujBqGUw
23
23
  singlestoredb/functions/ext/utils.py,sha256=OPMFD-tTCx2Kk9jguQkrTr7e4AgNkt15YsvaT1YSmN8,5480
24
24
  singlestoredb/fusion/__init__.py,sha256=FHWtrg6OJFTf6Ye197V5sU6ssryr2h6FBcDIgXP7-H4,367
25
25
  singlestoredb/fusion/graphql.py,sha256=SHqsPe4xgawdsTPHEtJGQlybYGWqPrGMmyK-v20RLac,5420
26
- singlestoredb/fusion/handler.py,sha256=PZXPWFhd3BaFtnpJqK2cFTw8oOaUVGIh1cS6BvltzKk,22308
26
+ singlestoredb/fusion/handler.py,sha256=XjxyMsTaTp1MYqtYCb5rOId4RD1zye9qqFYgCZmWcM0,25808
27
27
  singlestoredb/fusion/registry.py,sha256=_eT1gd38VPlFKs5f9Pu6lqQyoDQ_ixW5O56QwYLQ89Y,6361
28
28
  singlestoredb/fusion/result.py,sha256=EcFY5Qv43ySlQsfl_JB-I3ko7PzVdjuhhoKN96uHSAM,12171
29
29
  singlestoredb/fusion/handlers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -38,7 +38,7 @@ singlestoredb/management/cluster.py,sha256=XfdBuTlrAG-mnW1BFKeoAr4YSE5IVgxLjbuBS
38
38
  singlestoredb/management/manager.py,sha256=uGNrUe3zhuP-HUqdfwvy4MdEXTCmq-FZKjIwZSc3hOM,9096
39
39
  singlestoredb/management/organization.py,sha256=MjZ_tIoJGZwF95yfQ_Adz8LHYwkrKyj3p5JHDk6rWHE,5187
40
40
  singlestoredb/management/region.py,sha256=oGoLLS88dE1GmY7GCc0BV7X3f7bWwKQyeXOVBFmK9Pk,1678
41
- singlestoredb/management/utils.py,sha256=Etb0ZLs1X1UXVnLG4blLxtdl-nEnH0CTarjPykkzTo0,11144
41
+ singlestoredb/management/utils.py,sha256=uXrKlMnzlHj3qWO2vWCJP9mykUzIfbBxzZNN2vdXCvo,11775
42
42
  singlestoredb/management/workspace.py,sha256=BBNa3Af5IaUAwtzHWrNTJXoc8anXJ7FiWH9yIvtg79Q,63610
43
43
  singlestoredb/mysql/__init__.py,sha256=CbpwzNUJPAmKPpIobC0-ugBta_RgHCMq7X7N75QLReY,4669
44
44
  singlestoredb/mysql/_auth.py,sha256=YaqqyvAHmeraBv3BM207rNveUVPM-mPnW20ts_ynVWg,8341
@@ -83,7 +83,7 @@ singlestoredb/mysql/tests/thirdparty/test_MySQLdb/test_MySQLdb_dbapi20.py,sha256
83
83
  singlestoredb/mysql/tests/thirdparty/test_MySQLdb/test_MySQLdb_nonstandard.py,sha256=K4EnQCWI_4ShmCv6xHSBDo0B2HVbJvGGYHWygp2bBBk,2920
84
84
  singlestoredb/notebook/__init__.py,sha256=XGvAnkjV_6MjaNv6aqxqDL3ovPApKmNX-2UYH1t0cec,549
85
85
  singlestoredb/notebook/_objects.py,sha256=rDfHGLLwrnuhVMOyNojzrGamykyfOQxZfH2EnFd8vEw,8256
86
- singlestoredb/notebook/_portal.py,sha256=lbZz1jtf2OjPBee6rPhVt5r8wQMijlsHvKUa6xBI46U,8766
86
+ singlestoredb/notebook/_portal.py,sha256=uMjc1LnwpSfkuQehyOxUu3WBAUdKU9EaYAJBdTDw_8E,8767
87
87
  singlestoredb/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
88
88
  singlestoredb/tests/empty.sql,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
89
89
  singlestoredb/tests/local_infile.csv,sha256=0fYxcZcTvcwS2McF4sktFsipRY1G-ClGmCRR1eCqdEQ,45
@@ -115,9 +115,9 @@ singlestoredb/utils/events.py,sha256=rC9cHAetua_E1f-EiFkFM-gJzQSQIH5Uk-4sspC3KjI
115
115
  singlestoredb/utils/mogrify.py,sha256=gCcn99-vgsGVjTUV7RHJ6hH4vCNrsGB_Xo4z8kiSPDQ,4201
116
116
  singlestoredb/utils/results.py,sha256=wR70LhCqlobniZf52r67zYLBOKjWHQm68NAskdRQND8,15862
117
117
  singlestoredb/utils/xdict.py,sha256=-wi1lSPTnY99fhVMBhPKJ8cCsQhNG4GMUfkEBDKYgCw,13321
118
- singlestoredb-1.4.1.dist-info/LICENSE,sha256=Bojenzui8aPNjlF3w4ojguDP7sTf8vFV_9Gc2UAG1sg,11542
119
- singlestoredb-1.4.1.dist-info/METADATA,sha256=S5GEdMuhGBUw8es-v-pSlzDVzQNo8OT_7A4CLCD11pU,5710
120
- singlestoredb-1.4.1.dist-info/WHEEL,sha256=c4k7z5HB0t-y0nBCv6KyJ6KCjn8SEGPddD0lhaPtU3E,96
121
- singlestoredb-1.4.1.dist-info/entry_points.txt,sha256=bSLaTWB5zGjpVYPAaI46MkkDup0su-eb3uAhCNYuRV0,48
122
- singlestoredb-1.4.1.dist-info/top_level.txt,sha256=SDtemIXf-Kp-_F2f_S6x0db33cHGOILdAEsIQZe2LZc,35
123
- singlestoredb-1.4.1.dist-info/RECORD,,
118
+ singlestoredb-1.4.3.dist-info/LICENSE,sha256=Bojenzui8aPNjlF3w4ojguDP7sTf8vFV_9Gc2UAG1sg,11542
119
+ singlestoredb-1.4.3.dist-info/METADATA,sha256=JN_3ss7jeom5-_yVxjoSS-zCxNGwFTiqHEE5X991QZk,5710
120
+ singlestoredb-1.4.3.dist-info/WHEEL,sha256=c4k7z5HB0t-y0nBCv6KyJ6KCjn8SEGPddD0lhaPtU3E,96
121
+ singlestoredb-1.4.3.dist-info/entry_points.txt,sha256=bSLaTWB5zGjpVYPAaI46MkkDup0su-eb3uAhCNYuRV0,48
122
+ singlestoredb-1.4.3.dist-info/top_level.txt,sha256=SDtemIXf-Kp-_F2f_S6x0db33cHGOILdAEsIQZe2LZc,35
123
+ singlestoredb-1.4.3.dist-info/RECORD,,