singlestoredb 1.16.1__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.
Files changed (183) hide show
  1. singlestoredb/__init__.py +75 -0
  2. singlestoredb/ai/__init__.py +2 -0
  3. singlestoredb/ai/chat.py +139 -0
  4. singlestoredb/ai/embeddings.py +128 -0
  5. singlestoredb/alchemy/__init__.py +90 -0
  6. singlestoredb/apps/__init__.py +3 -0
  7. singlestoredb/apps/_cloud_functions.py +90 -0
  8. singlestoredb/apps/_config.py +72 -0
  9. singlestoredb/apps/_connection_info.py +18 -0
  10. singlestoredb/apps/_dashboards.py +47 -0
  11. singlestoredb/apps/_process.py +32 -0
  12. singlestoredb/apps/_python_udfs.py +100 -0
  13. singlestoredb/apps/_stdout_supress.py +30 -0
  14. singlestoredb/apps/_uvicorn_util.py +36 -0
  15. singlestoredb/auth.py +245 -0
  16. singlestoredb/config.py +484 -0
  17. singlestoredb/connection.py +1487 -0
  18. singlestoredb/converters.py +950 -0
  19. singlestoredb/docstring/__init__.py +33 -0
  20. singlestoredb/docstring/attrdoc.py +126 -0
  21. singlestoredb/docstring/common.py +230 -0
  22. singlestoredb/docstring/epydoc.py +267 -0
  23. singlestoredb/docstring/google.py +412 -0
  24. singlestoredb/docstring/numpydoc.py +562 -0
  25. singlestoredb/docstring/parser.py +100 -0
  26. singlestoredb/docstring/py.typed +1 -0
  27. singlestoredb/docstring/rest.py +256 -0
  28. singlestoredb/docstring/tests/__init__.py +1 -0
  29. singlestoredb/docstring/tests/_pydoctor.py +21 -0
  30. singlestoredb/docstring/tests/test_epydoc.py +729 -0
  31. singlestoredb/docstring/tests/test_google.py +1007 -0
  32. singlestoredb/docstring/tests/test_numpydoc.py +1100 -0
  33. singlestoredb/docstring/tests/test_parse_from_object.py +109 -0
  34. singlestoredb/docstring/tests/test_parser.py +248 -0
  35. singlestoredb/docstring/tests/test_rest.py +547 -0
  36. singlestoredb/docstring/tests/test_util.py +70 -0
  37. singlestoredb/docstring/util.py +141 -0
  38. singlestoredb/exceptions.py +120 -0
  39. singlestoredb/functions/__init__.py +16 -0
  40. singlestoredb/functions/decorator.py +201 -0
  41. singlestoredb/functions/dtypes.py +1793 -0
  42. singlestoredb/functions/ext/__init__.py +1 -0
  43. singlestoredb/functions/ext/arrow.py +375 -0
  44. singlestoredb/functions/ext/asgi.py +2133 -0
  45. singlestoredb/functions/ext/json.py +420 -0
  46. singlestoredb/functions/ext/mmap.py +413 -0
  47. singlestoredb/functions/ext/rowdat_1.py +724 -0
  48. singlestoredb/functions/ext/timer.py +89 -0
  49. singlestoredb/functions/ext/utils.py +218 -0
  50. singlestoredb/functions/signature.py +1578 -0
  51. singlestoredb/functions/typing/__init__.py +41 -0
  52. singlestoredb/functions/typing/numpy.py +20 -0
  53. singlestoredb/functions/typing/pandas.py +2 -0
  54. singlestoredb/functions/typing/polars.py +2 -0
  55. singlestoredb/functions/typing/pyarrow.py +2 -0
  56. singlestoredb/functions/utils.py +421 -0
  57. singlestoredb/fusion/__init__.py +11 -0
  58. singlestoredb/fusion/graphql.py +213 -0
  59. singlestoredb/fusion/handler.py +916 -0
  60. singlestoredb/fusion/handlers/__init__.py +0 -0
  61. singlestoredb/fusion/handlers/export.py +525 -0
  62. singlestoredb/fusion/handlers/files.py +690 -0
  63. singlestoredb/fusion/handlers/job.py +660 -0
  64. singlestoredb/fusion/handlers/models.py +250 -0
  65. singlestoredb/fusion/handlers/stage.py +502 -0
  66. singlestoredb/fusion/handlers/utils.py +324 -0
  67. singlestoredb/fusion/handlers/workspace.py +956 -0
  68. singlestoredb/fusion/registry.py +249 -0
  69. singlestoredb/fusion/result.py +399 -0
  70. singlestoredb/http/__init__.py +27 -0
  71. singlestoredb/http/connection.py +1267 -0
  72. singlestoredb/magics/__init__.py +34 -0
  73. singlestoredb/magics/run_personal.py +137 -0
  74. singlestoredb/magics/run_shared.py +134 -0
  75. singlestoredb/management/__init__.py +9 -0
  76. singlestoredb/management/billing_usage.py +148 -0
  77. singlestoredb/management/cluster.py +462 -0
  78. singlestoredb/management/export.py +295 -0
  79. singlestoredb/management/files.py +1102 -0
  80. singlestoredb/management/inference_api.py +105 -0
  81. singlestoredb/management/job.py +887 -0
  82. singlestoredb/management/manager.py +373 -0
  83. singlestoredb/management/organization.py +226 -0
  84. singlestoredb/management/region.py +169 -0
  85. singlestoredb/management/utils.py +423 -0
  86. singlestoredb/management/workspace.py +1927 -0
  87. singlestoredb/mysql/__init__.py +177 -0
  88. singlestoredb/mysql/_auth.py +298 -0
  89. singlestoredb/mysql/charset.py +214 -0
  90. singlestoredb/mysql/connection.py +2032 -0
  91. singlestoredb/mysql/constants/CLIENT.py +38 -0
  92. singlestoredb/mysql/constants/COMMAND.py +32 -0
  93. singlestoredb/mysql/constants/CR.py +78 -0
  94. singlestoredb/mysql/constants/ER.py +474 -0
  95. singlestoredb/mysql/constants/EXTENDED_TYPE.py +3 -0
  96. singlestoredb/mysql/constants/FIELD_TYPE.py +48 -0
  97. singlestoredb/mysql/constants/FLAG.py +15 -0
  98. singlestoredb/mysql/constants/SERVER_STATUS.py +10 -0
  99. singlestoredb/mysql/constants/VECTOR_TYPE.py +6 -0
  100. singlestoredb/mysql/constants/__init__.py +0 -0
  101. singlestoredb/mysql/converters.py +271 -0
  102. singlestoredb/mysql/cursors.py +896 -0
  103. singlestoredb/mysql/err.py +92 -0
  104. singlestoredb/mysql/optionfile.py +20 -0
  105. singlestoredb/mysql/protocol.py +450 -0
  106. singlestoredb/mysql/tests/__init__.py +19 -0
  107. singlestoredb/mysql/tests/base.py +126 -0
  108. singlestoredb/mysql/tests/conftest.py +37 -0
  109. singlestoredb/mysql/tests/test_DictCursor.py +132 -0
  110. singlestoredb/mysql/tests/test_SSCursor.py +141 -0
  111. singlestoredb/mysql/tests/test_basic.py +452 -0
  112. singlestoredb/mysql/tests/test_connection.py +851 -0
  113. singlestoredb/mysql/tests/test_converters.py +58 -0
  114. singlestoredb/mysql/tests/test_cursor.py +141 -0
  115. singlestoredb/mysql/tests/test_err.py +16 -0
  116. singlestoredb/mysql/tests/test_issues.py +514 -0
  117. singlestoredb/mysql/tests/test_load_local.py +75 -0
  118. singlestoredb/mysql/tests/test_nextset.py +88 -0
  119. singlestoredb/mysql/tests/test_optionfile.py +27 -0
  120. singlestoredb/mysql/tests/thirdparty/__init__.py +6 -0
  121. singlestoredb/mysql/tests/thirdparty/test_MySQLdb/__init__.py +9 -0
  122. singlestoredb/mysql/tests/thirdparty/test_MySQLdb/capabilities.py +323 -0
  123. singlestoredb/mysql/tests/thirdparty/test_MySQLdb/dbapi20.py +865 -0
  124. singlestoredb/mysql/tests/thirdparty/test_MySQLdb/test_MySQLdb_capabilities.py +110 -0
  125. singlestoredb/mysql/tests/thirdparty/test_MySQLdb/test_MySQLdb_dbapi20.py +224 -0
  126. singlestoredb/mysql/tests/thirdparty/test_MySQLdb/test_MySQLdb_nonstandard.py +101 -0
  127. singlestoredb/mysql/times.py +23 -0
  128. singlestoredb/notebook/__init__.py +16 -0
  129. singlestoredb/notebook/_objects.py +213 -0
  130. singlestoredb/notebook/_portal.py +352 -0
  131. singlestoredb/py.typed +0 -0
  132. singlestoredb/pytest.py +352 -0
  133. singlestoredb/server/__init__.py +0 -0
  134. singlestoredb/server/docker.py +452 -0
  135. singlestoredb/server/free_tier.py +267 -0
  136. singlestoredb/tests/__init__.py +0 -0
  137. singlestoredb/tests/alltypes.sql +307 -0
  138. singlestoredb/tests/alltypes_no_nulls.sql +208 -0
  139. singlestoredb/tests/empty.sql +0 -0
  140. singlestoredb/tests/ext_funcs/__init__.py +702 -0
  141. singlestoredb/tests/local_infile.csv +3 -0
  142. singlestoredb/tests/test.ipynb +18 -0
  143. singlestoredb/tests/test.sql +680 -0
  144. singlestoredb/tests/test2.ipynb +18 -0
  145. singlestoredb/tests/test2.sql +1 -0
  146. singlestoredb/tests/test_basics.py +1332 -0
  147. singlestoredb/tests/test_config.py +318 -0
  148. singlestoredb/tests/test_connection.py +3103 -0
  149. singlestoredb/tests/test_dbapi.py +27 -0
  150. singlestoredb/tests/test_exceptions.py +45 -0
  151. singlestoredb/tests/test_ext_func.py +1472 -0
  152. singlestoredb/tests/test_ext_func_data.py +1101 -0
  153. singlestoredb/tests/test_fusion.py +1527 -0
  154. singlestoredb/tests/test_http.py +288 -0
  155. singlestoredb/tests/test_management.py +1599 -0
  156. singlestoredb/tests/test_plugin.py +33 -0
  157. singlestoredb/tests/test_results.py +171 -0
  158. singlestoredb/tests/test_types.py +132 -0
  159. singlestoredb/tests/test_udf.py +737 -0
  160. singlestoredb/tests/test_udf_returns.py +459 -0
  161. singlestoredb/tests/test_vectorstore.py +51 -0
  162. singlestoredb/tests/test_xdict.py +333 -0
  163. singlestoredb/tests/utils.py +141 -0
  164. singlestoredb/types.py +373 -0
  165. singlestoredb/utils/__init__.py +0 -0
  166. singlestoredb/utils/config.py +950 -0
  167. singlestoredb/utils/convert_rows.py +69 -0
  168. singlestoredb/utils/debug.py +13 -0
  169. singlestoredb/utils/dtypes.py +205 -0
  170. singlestoredb/utils/events.py +65 -0
  171. singlestoredb/utils/mogrify.py +151 -0
  172. singlestoredb/utils/results.py +585 -0
  173. singlestoredb/utils/xdict.py +425 -0
  174. singlestoredb/vectorstore.py +192 -0
  175. singlestoredb/warnings.py +5 -0
  176. singlestoredb-1.16.1.dist-info/METADATA +165 -0
  177. singlestoredb-1.16.1.dist-info/RECORD +183 -0
  178. singlestoredb-1.16.1.dist-info/WHEEL +5 -0
  179. singlestoredb-1.16.1.dist-info/entry_points.txt +2 -0
  180. singlestoredb-1.16.1.dist-info/licenses/LICENSE +201 -0
  181. singlestoredb-1.16.1.dist-info/top_level.txt +3 -0
  182. sqlx/__init__.py +4 -0
  183. sqlx/magic.py +113 -0
@@ -0,0 +1,425 @@
1
+ #!/usr/bin/env python
2
+ #
3
+ # Copyright SAS Institute
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the License);
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+ # This file originally copied from https://github.com/sassoftware/python-swat
18
+ #
19
+ """Dictionary that allows setting nested keys by period (.) delimited strings."""
20
+ import copy
21
+ import re
22
+ from collections.abc import ItemsView
23
+ from collections.abc import Iterable
24
+ from collections.abc import KeysView
25
+ from collections.abc import ValuesView
26
+ from typing import Any
27
+ from typing import Dict
28
+ from typing import List
29
+ from typing import Tuple
30
+
31
+
32
+ def _is_compound_key(key: str) -> bool:
33
+ """
34
+ Check for a compound key name.
35
+
36
+ Parameters
37
+ ----------
38
+ key : string
39
+ The key name to check
40
+
41
+ Returns
42
+ -------
43
+ True
44
+ If the key is compound (i.e., contains a '.')
45
+ False
46
+ If the key is not compound
47
+
48
+ """
49
+ return isinstance(key, str) and '.' in key
50
+
51
+
52
+ class xdict(Dict[str, Any]):
53
+ """
54
+ Nested dictionary that allows setting of nested keys using '.' delimited strings.
55
+
56
+ Keys with a '.' in them automatically get split into separate keys.
57
+ Each '.' in a key represents another level of nesting in the resulting
58
+ dictionary.
59
+
60
+ Parameters
61
+ ----------
62
+ *args, **kwargs : Arbitrary arguments and keyword arguments
63
+ Same arguments as `dict`
64
+
65
+ Returns
66
+ -------
67
+ xdict object
68
+
69
+ Examples
70
+ --------
71
+ >>> dct = xdict()
72
+ >>> dct['a.b.c'] = 100
73
+ {'a': {'b': {'c': 100}}}
74
+
75
+ """
76
+
77
+ _dir: List[str]
78
+
79
+ def __init__(self, *args: Any, **kwargs: Any):
80
+ super(xdict, self).__init__()
81
+ self.update(*args, **kwargs)
82
+
83
+ def __dir__(self) -> Iterable[str]:
84
+ """Return keys in the dict."""
85
+ if hasattr(self, '_dir') and self._dir:
86
+ return list(self._dir)
87
+ return super(xdict, self).__dir__()
88
+
89
+ def set_dir_values(self, values: List[str]) -> None:
90
+ """
91
+ Set the valid values for keys to display in tab-completion.
92
+
93
+ Parameters
94
+ ----------
95
+ values : list of strs
96
+ The values to display
97
+
98
+ """
99
+ super(xdict, self).__setattr__('_dir', values)
100
+
101
+ def set_doc(self, docstring: str) -> None:
102
+ """Set the docstring for the xdict."""
103
+ super(xdict, self).__setattr__('__doc__', docstring)
104
+
105
+ def __copy__(self) -> 'xdict':
106
+ """Return a copy of self."""
107
+ return type(self)(**self)
108
+
109
+ def __deepcopy__(self, memo: Any) -> 'xdict':
110
+ """Return a deep copy of self."""
111
+ out = type(self)()
112
+ for key, value in self.items():
113
+ if isinstance(value, (dict, list, tuple, set)):
114
+ value = copy.deepcopy(value)
115
+ out[key] = value
116
+ return out
117
+
118
+ @classmethod
119
+ def from_json(cls, jsonstr: str) -> 'xdict':
120
+ """
121
+ Create an xdict object from a JSON string.
122
+
123
+ Parameters
124
+ ----------
125
+ jsonstr : string
126
+ Valid JSON string that represents an object
127
+
128
+ Returns
129
+ -------
130
+ xdict object
131
+
132
+ """
133
+ import json
134
+ out = cls()
135
+ out.update(json.loads(jsonstr))
136
+ return out
137
+
138
+ def __setitem__(self, key: str, value: Any) -> Any:
139
+ """Set a key/value pair in an xdict object."""
140
+ if isinstance(value, dict) and not isinstance(value, type(self)):
141
+ value = type(self)(value)
142
+ if _is_compound_key(key):
143
+ return self._xset(key, value)
144
+ return super(xdict, self).__setitem__(key, value)
145
+
146
+ def _xset(self, key: str, value: Any) -> Any:
147
+ """
148
+ Set a key/value pair allowing nested levels in the key.
149
+
150
+ Parameters
151
+ ----------
152
+ key : any
153
+ Key value, if it is a string delimited by periods (.), each
154
+ period represents another level of nesting of xdict objects.
155
+ value : any
156
+ Data value
157
+
158
+ """
159
+ if isinstance(value, dict) and not isinstance(value, type(self)):
160
+ value = type(self)(value)
161
+ if _is_compound_key(key):
162
+ current, key = key.split('.', 1)
163
+ if current not in self:
164
+ self[current] = type(self)()
165
+ return self[current]._xset(key, value)
166
+ self[key] = value
167
+ return None
168
+
169
+ def setdefault(self, key: str, *default: Any) -> Any:
170
+ """Return keyed value, or set it to `default` if missing."""
171
+ if _is_compound_key(key):
172
+ try:
173
+ return self[key]
174
+ except KeyError:
175
+ if default:
176
+ new_default = default[0]
177
+ if isinstance(default, dict) and not isinstance(default, type(self)):
178
+ new_default = type(self)(default)
179
+ else:
180
+ new_default = None
181
+ self[key] = new_default
182
+ return new_default
183
+ return super(xdict, self).setdefault(key, *default)
184
+
185
+ def __contains__(self, key: object) -> bool:
186
+ """Does the xdict contain `key`?."""
187
+ if super(xdict, self).__contains__(key):
188
+ return True
189
+ return key in self.allkeys()
190
+
191
+ has_key = __contains__
192
+
193
+ def __getitem__(self, key: str) -> Any:
194
+ """Get value stored at `key`."""
195
+ if _is_compound_key(key):
196
+ return self._xget(key)
197
+ return super(xdict, self).__getitem__(key)
198
+
199
+ def _xget(self, key: str, *default: Any) -> Any:
200
+ """
201
+ Return keyed value, or `default` if missing
202
+
203
+ Parameters
204
+ ----------
205
+ key : any
206
+ Key to look up
207
+ *default : any
208
+ Default value to return if key is missing
209
+
210
+ Returns
211
+ -------
212
+ Any
213
+
214
+ """
215
+ if _is_compound_key(key):
216
+ current, key = key.split('.', 1)
217
+ try:
218
+ return self[current]._xget(key)
219
+ except KeyError:
220
+ if default:
221
+ return default[0]
222
+ raise KeyError(key)
223
+ return self[key]
224
+
225
+ def get(self, key: str, *default: Any) -> Any:
226
+ """Return keyed value, or `default` if missing."""
227
+ if _is_compound_key(key):
228
+ return self._xget(key, *default)
229
+ return super(xdict, self).get(key, *default)
230
+
231
+ def __delitem__(self, key: str) -> Any:
232
+ """Deleted keyed item."""
233
+ if _is_compound_key(key):
234
+ return self._xdel(key)
235
+ super(xdict, self).__delitem__(key)
236
+
237
+ def _xdel(self, key: str) -> Any:
238
+ """
239
+ Delete keyed item.
240
+
241
+ Parameters
242
+ ----------
243
+ key : any
244
+ Key to delete. If it is a string that is period (.) delimited,
245
+ each period represents another level of nesting of xdict objects.
246
+
247
+ """
248
+ if _is_compound_key(key):
249
+ current, key = key.split('.', 1)
250
+ try:
251
+ return self[current]._xdel(key)
252
+ except KeyError:
253
+ raise KeyError(key)
254
+ del self[key]
255
+
256
+ def pop(self, key: str, *default: Any) -> Any:
257
+ """Remove and return value stored at `key`."""
258
+ try:
259
+ out = self[key]
260
+ del self[key]
261
+ return out
262
+ except KeyError:
263
+ if default:
264
+ return default[0]
265
+ raise KeyError(key)
266
+
267
+ def _flatten(
268
+ self,
269
+ dct: Dict[str, Any],
270
+ output: Dict[str, Any],
271
+ prefix: str = '',
272
+ ) -> None:
273
+ """
274
+ Create a new dict with keys flattened to period (.) delimited keys
275
+
276
+ Parameters
277
+ ----------
278
+ dct : dict
279
+ The dictionary to flatten
280
+ output : dict
281
+ The resulting dictionary (used internally in recursion)
282
+ prefix : string
283
+ Key prefix built from upper levels of nesting
284
+
285
+ Returns
286
+ -------
287
+ dict
288
+
289
+ """
290
+ if prefix:
291
+ prefix = prefix + '.'
292
+ for key, value in dct.items():
293
+ if isinstance(value, dict):
294
+ if isinstance(key, int):
295
+ intkey = '%s[%s]' % (re.sub(r'\.$', r'', prefix), key)
296
+ self._flatten(value, prefix=intkey, output=output)
297
+ else:
298
+ self._flatten(value, prefix=prefix + key, output=output)
299
+ else:
300
+ if isinstance(key, int):
301
+ intkey = '%s[%s]' % (re.sub(r'\.$', r'', prefix), key)
302
+ output[intkey] = value
303
+ else:
304
+ output[prefix + key] = value
305
+
306
+ def flattened(self) -> Dict[str, Any]:
307
+ """Return an xdict with keys flattened to period (.) delimited strings."""
308
+ output: Dict[str, Any] = {}
309
+ self._flatten(self, output)
310
+ return output
311
+
312
+ def allkeys(self) -> List[str]:
313
+ """Return a list of all possible keys (even sub-keys) in the xdict."""
314
+ out = set()
315
+ for key in self.flatkeys():
316
+ out.add(key)
317
+ while '.' in key:
318
+ key = key.rsplit('.', 1)[0]
319
+ out.add(key)
320
+ if '[' in key:
321
+ out.add(re.sub(r'\[\d+\]', r'', key))
322
+ return list(out)
323
+
324
+ def flatkeys(self) -> List[str]:
325
+ """Return a list of flattened keys in the xdict."""
326
+ return list(self.flattened().keys())
327
+
328
+ def flatvalues(self) -> List[Any]:
329
+ """Return a list of flattened values in the xdict."""
330
+ return list(self.flattened().values())
331
+
332
+ def flatitems(self) -> List[Tuple[str, Any]]:
333
+ """Return tuples of flattened key/value pairs."""
334
+ return list(self.flattened().items())
335
+
336
+ def iterflatkeys(self) -> Iterable[str]:
337
+ """Return iterator of flattened keys."""
338
+ return iter(self.flattened().keys())
339
+
340
+ def iterflatvalues(self) -> Iterable[Any]:
341
+ """Return iterator of flattened values."""
342
+ return iter(self.flattened().values())
343
+
344
+ def iterflatitems(self) -> Iterable[Tuple[str, Any]]:
345
+ """Return iterator of flattened items."""
346
+ return iter(self.flattened().items())
347
+
348
+ def viewflatkeys(self) -> KeysView[str]:
349
+ """Return view of flattened keys."""
350
+ return self.flattened().keys()
351
+
352
+ def viewflatvalues(self) -> ValuesView[Any]:
353
+ """Return view of flattened values."""
354
+ return self.flattened().values()
355
+
356
+ def viewflatitems(self) -> ItemsView[str, Any]:
357
+ """Return view of flattened items."""
358
+ return self.flattened().items()
359
+
360
+ def update(self, *args: Any, **kwargs: Any) -> None:
361
+ """Merge the key/value pairs into `self`."""
362
+ for arg in args:
363
+ if isinstance(arg, dict):
364
+ for key, value in arg.items():
365
+ self._xset(key, value)
366
+ else:
367
+ for key, value in arg:
368
+ self._xset(key, value)
369
+ for key, value in kwargs.items():
370
+ self._xset(key, value)
371
+
372
+ def to_json(self) -> str:
373
+ """
374
+ Convert an xdict object to a JSON string.
375
+
376
+ Returns
377
+ -------
378
+ str
379
+
380
+ """
381
+ import json
382
+ return json.dumps(self)
383
+
384
+
385
+ class xadict(xdict):
386
+ """An xdict that also allows setting/getting/deleting keys as attributes."""
387
+
388
+ getdoc = None
389
+ trait_names = None
390
+
391
+ def _getAttributeNames(self) -> None:
392
+ """Block this from creating attributes."""
393
+ return
394
+
395
+ def __delattr__(self, key: str) -> Any:
396
+ """Delete the attribute stored at `key`."""
397
+ if key.startswith('_') and key.endswith('_'):
398
+ return super(xadict, self).__delattr__(key)
399
+ del self[key]
400
+
401
+ def __getattr__(self, key: str) -> Any:
402
+ """Get the attribute store at `key`."""
403
+ if key.startswith('_') and key.endswith('_'):
404
+ return super(xadict, self).__getattr__(key) # type: ignore
405
+ try:
406
+ return self[key]
407
+ except KeyError:
408
+ dct = type(self)()
409
+ self[key] = dct
410
+ return dct
411
+ return None
412
+
413
+ def __getitem__(self, key: str) -> Any:
414
+ """Get item of an integer creates a new dict."""
415
+ if isinstance(key, int) and key not in self:
416
+ out = type(self)()
417
+ self[key] = out
418
+ return out
419
+ return super(xadict, self).__getitem__(key)
420
+
421
+ def __setattr__(self, key: str, value: Any) -> Any:
422
+ """Set the attribute stored at `key`."""
423
+ if key.startswith('_') and key.endswith('_'):
424
+ return super(xadict, self).__setattr__(key, value)
425
+ self[key] = value
@@ -0,0 +1,192 @@
1
+ from typing import Any
2
+ from typing import Callable
3
+ from typing import Dict
4
+ from typing import Optional
5
+
6
+ from vectorstore import AndFilter # noqa: F401
7
+ from vectorstore import DeletionProtection # noqa: F401
8
+ from vectorstore import EqFilter # noqa: F401
9
+ from vectorstore import ExactMatchFilter # noqa: F401
10
+ from vectorstore import FilterTypedDict # noqa: F401
11
+ from vectorstore import GteFilter # noqa: F401
12
+ from vectorstore import GtFilter # noqa: F401
13
+ from vectorstore import IndexInterface # noqa: F401
14
+ from vectorstore import IndexList # noqa: F401
15
+ from vectorstore import IndexModel # noqa: F401
16
+ from vectorstore import IndexStatsTypedDict # noqa: F401
17
+ from vectorstore import InFilter # noqa: F401
18
+ from vectorstore import LteFilter # noqa: F401
19
+ from vectorstore import LtFilter # noqa: F401
20
+ from vectorstore import MatchTypedDict # noqa: F401
21
+ from vectorstore import Metric # noqa: F401
22
+ from vectorstore import NamespaceStatsTypedDict # noqa: F401
23
+ from vectorstore import NeFilter # noqa: F401
24
+ from vectorstore import NinFilter # noqa: F401
25
+ from vectorstore import OrFilter # noqa: F401
26
+ from vectorstore import SimpleFilter # noqa: F401
27
+ from vectorstore import Vector # noqa: F401
28
+ from vectorstore import VectorDictMetadataValue # noqa: F401
29
+ from vectorstore import VectorMetadataTypedDict # noqa: F401
30
+ from vectorstore import VectorTuple # noqa: F401
31
+ from vectorstore import VectorTupleWithMetadata # noqa: F401
32
+
33
+
34
+ def vector_db(
35
+ host: Optional[str] = None, user: Optional[str] = None,
36
+ password: Optional[str] = None, port: Optional[int] = None,
37
+ database: Optional[str] = None, driver: Optional[str] = None,
38
+ pure_python: Optional[bool] = None, local_infile: Optional[bool] = None,
39
+ charset: Optional[str] = None,
40
+ ssl_key: Optional[str] = None, ssl_cert: Optional[str] = None,
41
+ ssl_ca: Optional[str] = None, ssl_disabled: Optional[bool] = None,
42
+ ssl_cipher: Optional[str] = None, ssl_verify_cert: Optional[bool] = None,
43
+ tls_sni_servername: Optional[str] = None,
44
+ ssl_verify_identity: Optional[bool] = None,
45
+ conv: Optional[Dict[int, Callable[..., Any]]] = None,
46
+ credential_type: Optional[str] = None,
47
+ autocommit: Optional[bool] = None,
48
+ results_type: Optional[str] = None,
49
+ buffered: Optional[bool] = None,
50
+ results_format: Optional[str] = None,
51
+ program_name: Optional[str] = None,
52
+ conn_attrs: Optional[Dict[str, str]] = {},
53
+ multi_statements: Optional[bool] = None,
54
+ client_found_rows: Optional[bool] = None,
55
+ connect_timeout: Optional[int] = None,
56
+ nan_as_null: Optional[bool] = None,
57
+ inf_as_null: Optional[bool] = None,
58
+ encoding_errors: Optional[str] = None,
59
+ track_env: Optional[bool] = None,
60
+ enable_extended_data_types: Optional[bool] = None,
61
+ vector_data_format: Optional[str] = None,
62
+ parse_json: Optional[bool] = None,
63
+ pool_size: Optional[int] = 5,
64
+ max_overflow: Optional[int] = 10,
65
+ timeout: Optional[float] = 30,
66
+ ) -> Any:
67
+ """
68
+ Return a vectorstore API connection.
69
+ Database should be specified in the URL or as a keyword.
70
+
71
+ Parameters
72
+ ----------
73
+ host : str, optional
74
+ Hostname, IP address, or URL that describes the connection.
75
+ The scheme or protocol defines which database connector to use.
76
+ By default, the ``mysql`` scheme is used. To connect to the
77
+ HTTP API, the scheme can be set to ``http`` or ``https``. The username,
78
+ password, host, and port are specified as in a standard URL. The path
79
+ indicates the database name. The overall form of the URL is:
80
+ ``scheme://user:password@host:port/db_name``. The scheme can
81
+ typically be left off (unless you are using the HTTP API):
82
+ ``user:password@host:port/db_name``.
83
+ user : str, optional
84
+ Database user name
85
+ password : str, optional
86
+ Database user password
87
+ port : int, optional
88
+ Database port. This defaults to 3306 for non-HTTP connections, 80
89
+ for HTTP connections, and 443 for HTTPS connections.
90
+ database : str, optional
91
+ Database name.
92
+ pure_python : bool, optional
93
+ Use the connector in pure Python mode
94
+ local_infile : bool, optional
95
+ Allow local file uploads
96
+ charset : str, optional
97
+ Character set for string values
98
+ ssl_key : str, optional
99
+ File containing SSL key
100
+ ssl_cert : str, optional
101
+ File containing SSL certificate
102
+ ssl_ca : str, optional
103
+ File containing SSL certificate authority
104
+ ssl_cipher : str, optional
105
+ Sets the SSL cipher list
106
+ ssl_disabled : bool, optional
107
+ Disable SSL usage
108
+ ssl_verify_cert : bool, optional
109
+ Verify the server's certificate. This is automatically enabled if
110
+ ``ssl_ca`` is also specified.
111
+ ssl_verify_identity : bool, optional
112
+ Verify the server's identity
113
+ conv : dict[int, Callable], optional
114
+ Dictionary of data conversion functions
115
+ credential_type : str, optional
116
+ Type of authentication to use: auth.PASSWORD, auth.JWT, or auth.BROWSER_SSO
117
+ autocommit : bool, optional
118
+ Enable autocommits
119
+ results_type : str, optional
120
+ The form of the query results: tuples, namedtuples, dicts,
121
+ numpy, polars, pandas, arrow
122
+ buffered : bool, optional
123
+ Should the entire query result be buffered in memory? This is the default
124
+ behavior which allows full cursor control of the result, but does consume
125
+ more memory.
126
+ results_format : str, optional
127
+ Deprecated. This option has been renamed to results_type.
128
+ program_name : str, optional
129
+ Name of the program
130
+ conn_attrs : dict, optional
131
+ Additional connection attributes for telemetry. Example:
132
+ {'program_version': "1.0.2", "_connector_name": "dbt connector"}
133
+ multi_statements: bool, optional
134
+ Should multiple statements be allowed within a single query?
135
+ connect_timeout : int, optional
136
+ The timeout for connecting to the database in seconds.
137
+ (default: 10, min: 1, max: 31536000)
138
+ nan_as_null : bool, optional
139
+ Should NaN values be treated as NULLs when used in parameter
140
+ substitutions including uploaded data?
141
+ inf_as_null : bool, optional
142
+ Should Inf values be treated as NULLs when used in parameter
143
+ substitutions including uploaded data?
144
+ encoding_errors : str, optional
145
+ The error handler name for value decoding errors
146
+ track_env : bool, optional
147
+ Should the connection track the SINGLESTOREDB_URL environment variable?
148
+ enable_extended_data_types : bool, optional
149
+ Should extended data types (BSON, vector) be enabled?
150
+ vector_data_format : str, optional
151
+ Format for vector types: json or binary
152
+ pool_size : int, optional
153
+ The number of connections to keep in the connection pool. Default is 5.
154
+ max_overflow : int, optional
155
+ The maximum number of connections to allow beyond the pool size.
156
+ Default is 10.
157
+ timeout : float, optional
158
+ The timeout for acquiring a connection from the pool in seconds.
159
+ Default is 30 seconds.
160
+
161
+ See Also
162
+ --------
163
+ :class:`Connection`
164
+
165
+ Returns
166
+ -------
167
+ :class:`VectorDB`
168
+
169
+ """
170
+ from vectorstore import VectorDB
171
+ return VectorDB(
172
+ host=host, user=user, password=password, port=port,
173
+ database=database, driver=driver, pure_python=pure_python,
174
+ local_infile=local_infile, charset=charset,
175
+ ssl_key=ssl_key, ssl_cert=ssl_cert, ssl_ca=ssl_ca,
176
+ ssl_disabled=ssl_disabled, ssl_cipher=ssl_cipher,
177
+ ssl_verify_cert=ssl_verify_cert,
178
+ tls_sni_servername=tls_sni_servername,
179
+ ssl_verify_identity=ssl_verify_identity, conv=conv,
180
+ credential_type=credential_type, autocommit=autocommit,
181
+ results_type=results_type, buffered=buffered,
182
+ results_format=results_format, program_name=program_name,
183
+ conn_attrs=conn_attrs, multi_statements=multi_statements,
184
+ client_found_rows=client_found_rows,
185
+ connect_timeout=connect_timeout, nan_as_null=nan_as_null,
186
+ inf_as_null=inf_as_null, encoding_errors=encoding_errors,
187
+ track_env=track_env,
188
+ enable_extended_data_types=enable_extended_data_types,
189
+ vector_data_format=vector_data_format,
190
+ parse_json=parse_json, pool_size=pool_size,
191
+ max_overflow=max_overflow, timeout=timeout,
192
+ )
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env python
2
+
3
+ class PreviewFeatureWarning(UserWarning):
4
+ """Warning for experimental preview features."""
5
+ pass