singlestoredb 0.8.8__cp36-abi3-win_amd64.whl → 0.9.0__cp36-abi3-win_amd64.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.

Files changed (41) hide show
  1. _singlestoredb_accel.pyd +0 -0
  2. singlestoredb/__init__.py +1 -1
  3. singlestoredb/config.py +6 -0
  4. singlestoredb/exceptions.py +24 -0
  5. singlestoredb/functions/__init__.py +1 -0
  6. singlestoredb/functions/decorator.py +165 -0
  7. singlestoredb/functions/dtypes.py +1396 -0
  8. singlestoredb/functions/ext/__init__.py +2 -0
  9. singlestoredb/functions/ext/asgi.py +357 -0
  10. singlestoredb/functions/ext/json.py +49 -0
  11. singlestoredb/functions/ext/rowdat_1.py +111 -0
  12. singlestoredb/functions/signature.py +607 -0
  13. singlestoredb/management/billing_usage.py +148 -0
  14. singlestoredb/management/manager.py +42 -1
  15. singlestoredb/management/organization.py +85 -0
  16. singlestoredb/management/utils.py +118 -1
  17. singlestoredb/management/workspace.py +881 -5
  18. singlestoredb/mysql/__init__.py +12 -10
  19. singlestoredb/mysql/_auth.py +3 -1
  20. singlestoredb/mysql/charset.py +12 -11
  21. singlestoredb/mysql/connection.py +4 -3
  22. singlestoredb/mysql/constants/CLIENT.py +0 -1
  23. singlestoredb/mysql/constants/COMMAND.py +0 -1
  24. singlestoredb/mysql/constants/CR.py +0 -2
  25. singlestoredb/mysql/constants/ER.py +0 -1
  26. singlestoredb/mysql/constants/FIELD_TYPE.py +0 -1
  27. singlestoredb/mysql/constants/FLAG.py +0 -1
  28. singlestoredb/mysql/constants/SERVER_STATUS.py +0 -1
  29. singlestoredb/mysql/converters.py +49 -28
  30. singlestoredb/mysql/err.py +3 -3
  31. singlestoredb/mysql/optionfile.py +4 -4
  32. singlestoredb/mysql/protocol.py +2 -1
  33. singlestoredb/mysql/times.py +3 -4
  34. singlestoredb/tests/test2.sql +1 -0
  35. singlestoredb/tests/test_management.py +393 -3
  36. singlestoredb/tests/test_udf.py +698 -0
  37. {singlestoredb-0.8.8.dist-info → singlestoredb-0.9.0.dist-info}/METADATA +1 -1
  38. {singlestoredb-0.8.8.dist-info → singlestoredb-0.9.0.dist-info}/RECORD +41 -29
  39. {singlestoredb-0.8.8.dist-info → singlestoredb-0.9.0.dist-info}/LICENSE +0 -0
  40. {singlestoredb-0.8.8.dist-info → singlestoredb-0.9.0.dist-info}/WHEEL +0 -0
  41. {singlestoredb-0.8.8.dist-info → singlestoredb-0.9.0.dist-info}/top_level.txt +0 -0
_singlestoredb_accel.pyd CHANGED
Binary file
singlestoredb/__init__.py CHANGED
@@ -13,7 +13,7 @@ Examples
13
13
 
14
14
  """
15
15
 
16
- __version__ = '0.8.8'
16
+ __version__ = '0.9.0'
17
17
 
18
18
  from .alchemy import create_engine
19
19
  from .config import options, get_option, set_option, describe_option
singlestoredb/config.py CHANGED
@@ -250,3 +250,9 @@ register_option(
250
250
  'Print queries and parameters to stderr.',
251
251
  environ='SINGLESTOREDB_DEBUG_QUERIES',
252
252
  )
253
+
254
+ register_option(
255
+ 'debug.connection', 'bool', check_bool, False,
256
+ 'Print connection tracing information.',
257
+ environ='SINGLESTOREDB_DEBUG_CONNECTION',
258
+ )
@@ -94,3 +94,27 @@ class NotSupportedError(DatabaseError):
94
94
 
95
95
  class ManagementError(Error):
96
96
  """Exception for errors in the management API."""
97
+
98
+ def __init__(
99
+ self, errno: Optional[int] = None, msg: Optional[str] = None,
100
+ response: Optional[str] = None,
101
+ ):
102
+ self.errno = errno
103
+ self.errmsg = msg
104
+ self.response = response
105
+ super(Exception, self).__init__(errno, msg)
106
+
107
+ def __str__(self) -> str:
108
+ """Return string representation."""
109
+ prefix = []
110
+ if self.errno is not None:
111
+ prefix.append(f'{self.errno}')
112
+ if self.response is not None:
113
+ prefix.append(f'({self.response})')
114
+ if prefix and self.errmsg:
115
+ return ' '.join(prefix) + ': ' + self.errmsg
116
+ elif prefix:
117
+ return ' '.join(prefix)
118
+ elif self.errmsg:
119
+ return f'{self.errmsg}'
120
+ return 'Unknown error'
@@ -0,0 +1 @@
1
+ from .decorator import udf # noqa: F401
@@ -0,0 +1,165 @@
1
+ import functools
2
+ from typing import Any
3
+ from typing import Callable
4
+ from typing import Dict
5
+ from typing import List
6
+ from typing import Optional
7
+ from typing import Union
8
+
9
+ from .dtypes import DataType
10
+
11
+
12
+ def listify(x: Any) -> List[Any]:
13
+ """Make sure sure value is a list."""
14
+ if x is None:
15
+ return []
16
+ if isinstance(x, (list, tuple, set)):
17
+ return list(x)
18
+ return [x]
19
+
20
+
21
+ def udf(
22
+ func: Optional[Callable[..., Any]] = None,
23
+ *,
24
+ name: Optional[str] = None,
25
+ database: Optional[str] = None,
26
+ environment: Optional[str] = None,
27
+ packages: Optional[Union[str, List[str]]] = None,
28
+ resources: Optional[Union[str, List[str]]] = None,
29
+ max_batch_size: int = 500,
30
+ n_processes: int = 1,
31
+ n_instances: int = 1,
32
+ args: Optional[Union[DataType, List[DataType], Dict[str, DataType]]] = None,
33
+ returns: Optional[str] = None,
34
+ replace: bool = False,
35
+ remote_service: Optional[str] = None,
36
+ link: Optional[str] = None,
37
+ ) -> Callable[..., Any]:
38
+ """
39
+ Apply attributes to a UDF.
40
+
41
+ Parameters
42
+ ----------
43
+ func : callable, optional
44
+ The UDF to apply parameters to
45
+ name : str, optional
46
+ The name to use for the UDF in the database
47
+ database : str, optional
48
+ The database to create the functions in
49
+ environment : str, optional
50
+ The environment to create for the functions
51
+ packages : str or list-of-strs, optional
52
+ The package dependency specifications. Strings must be in the
53
+ format used in requirements.txt files.
54
+ max_match_size : int, optional
55
+ The number of rows to batch in the server before sending
56
+ them to the UDF application
57
+ n_processes : int, optional
58
+ The number of sub-processes to spin up to process sub-batches
59
+ of rows of data. This may be used if the UDF is CPU-intensive
60
+ and there are free CPUs in the server the web application
61
+ is running in. If the UDF is very short-running, setting this
62
+ parameter to greater than one will likey cause the UDF to
63
+ run slower since the overhead of the extra processes and moving
64
+ data would be the limiting factor.
65
+ n_instances : int, optional
66
+ The number of runtime environments to use to handle data
67
+ processing requests
68
+ args : str | Callable | List[str | Callable] | Dict[str, str | Callable], optional
69
+ Specifies the data types of the function arguments. Typically,
70
+ the function data types are derived from the function parameter
71
+ annotations. These annotations can be overridden. If the function
72
+ takes a single type for all parameters, `args` can be set to a
73
+ SQL string describing all parameters. If the function takes more
74
+ than one parameter and all of the parameters are being manually
75
+ defined, a list of SQL strings may be used (one for each parameter).
76
+ A dictionary of SQL strings may be used to specify a parameter type
77
+ for a subset of parameters; the keys are the names of the
78
+ function parameters. Callables may also be used for datatypes. This
79
+ is primarily for using the functions in the ``dtypes`` module that
80
+ are associated with SQL types with all default options (e.g., ``dt.FLOAT``).
81
+ returns : str, optional
82
+ Specifies the return data type of the function. If not specified,
83
+ the type annotation from the function is used.
84
+ replace : bool, optional
85
+ Should an existing function of the same name be replaced when
86
+ creating the function in the database?
87
+ remote_service : str, optional
88
+ URL of the remote service that handles this function. If using an
89
+ environment, this URL is generated automatically.
90
+ link : str, optional
91
+ Name of link to use to connect to remote service
92
+
93
+ Returns
94
+ -------
95
+ Callable
96
+
97
+ """
98
+ assert max_batch_size >= 1
99
+ assert n_processes >= 1
100
+ assert n_instances >= 1
101
+
102
+ if args is None:
103
+ pass
104
+ elif isinstance(args, (list, tuple)):
105
+ args = list(args)
106
+ for i, item in enumerate(args):
107
+ if callable(item):
108
+ args[i] = item()
109
+ for item in args:
110
+ if not isinstance(item, str):
111
+ raise TypeError(f'unrecognized type for parameter: {item}')
112
+ elif isinstance(args, dict):
113
+ args = dict(args)
114
+ for k, v in list(args.items()):
115
+ if callable(v):
116
+ args[k] = v()
117
+ for item in args.values():
118
+ if not isinstance(item, str):
119
+ raise TypeError(f'unrecognized type for parameter: {item}')
120
+ elif callable(args):
121
+ args = args()
122
+ elif isinstance(args, str):
123
+ args = args
124
+ else:
125
+ raise TypeError(f'unrecognized data type for args: {args}')
126
+
127
+ if returns is None:
128
+ pass
129
+ elif callable(returns):
130
+ returns = returns()
131
+ elif isinstance(returns, str):
132
+ returns = returns
133
+ else:
134
+ raise TypeError(f'unrecognized return type: {returns}')
135
+
136
+ if returns is not None and not isinstance(returns, str):
137
+ raise TypeError(f'unrecognized return type: {returns}')
138
+
139
+ def wrapper(*args: Any, **kwargs: Any) -> Callable[..., Any]:
140
+ return func(*args, **kwargs) # type: ignore
141
+
142
+ wrapper._singlestoredb_attrs = { # type: ignore
143
+ k: v for k, v in dict(
144
+ name=name,
145
+ database=database,
146
+ environment=environment,
147
+ packages=listify(packages),
148
+ resources=listify(resources),
149
+ max_batch_size=max(1, int(max_batch_size)),
150
+ n_processes=max(1, int(n_processes)),
151
+ n_instances=max(1, int(n_instances)),
152
+ args=args,
153
+ returns=returns,
154
+ replace=bool(replace),
155
+ remote_service=remote_service,
156
+ link=link,
157
+ ).items() if v is not None
158
+ }
159
+
160
+ if func is None:
161
+ def decorate(func: Callable[..., Any]) -> Callable[..., Any]:
162
+ return functools.wraps(func)(wrapper)
163
+ return decorate
164
+
165
+ return functools.wraps(func)(wrapper)