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

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
@@ -1,4 +1,3 @@
1
- # type: ignore
2
1
  """
3
2
  PyMySQL: A pure-Python MySQL client library.
4
3
 
@@ -23,6 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
22
  THE SOFTWARE.
24
23
  """
25
24
  import sys
25
+ from typing import Any
26
+ from typing import FrozenSet
26
27
 
27
28
  from .constants import FIELD_TYPE
28
29
  from .err import DatabaseError
@@ -51,20 +52,21 @@ paramstyle = 'pyformat'
51
52
  from . import connection # noqa: E402
52
53
 
53
54
 
54
- class DBAPISet(frozenset):
55
- def __ne__(self, other):
55
+ class DBAPISet(FrozenSet[Any]):
56
+
57
+ def __ne__(self, other: Any) -> bool:
56
58
  if isinstance(other, set):
57
59
  return frozenset.__ne__(self, other)
58
60
  else:
59
61
  return other not in self
60
62
 
61
- def __eq__(self, other):
63
+ def __eq__(self, other: Any) -> bool:
62
64
  if isinstance(other, frozenset):
63
65
  return frozenset.__eq__(self, other)
64
66
  else:
65
67
  return other in self
66
68
 
67
- def __hash__(self):
69
+ def __hash__(self) -> int:
68
70
  return frozenset.__hash__(self)
69
71
 
70
72
 
@@ -96,15 +98,15 @@ DATETIME = TIMESTAMP
96
98
  ROWID = DBAPISet()
97
99
 
98
100
 
99
- def Binary(x):
101
+ def Binary(x: Any) -> bytes:
100
102
  """Return x as a binary type."""
101
103
  return bytes(x)
102
104
 
103
105
 
104
- Connect = connect = Connection = connection.Connection
106
+ Connect = connect = Connection = connection.Connection # type: ignore
105
107
 
106
108
 
107
- def get_client_info(): # for MySQLdb compatibility
109
+ def get_client_info() -> str: # for MySQLdb compatibility
108
110
  from .. import __version__
109
111
  return __version__
110
112
 
@@ -117,11 +119,11 @@ NULL = 'NULL'
117
119
  __version__ = get_client_info()
118
120
 
119
121
 
120
- def thread_safe():
122
+ def thread_safe() -> bool:
121
123
  return True # match MySQLdb.thread_safe()
122
124
 
123
125
 
124
- def install_as_MySQLdb():
126
+ def install_as_MySQLdb() -> None:
125
127
  """
126
128
  After this function is called, any application that imports MySQLdb or
127
129
  _mysql will unwittingly actually use pymysql.
@@ -16,8 +16,10 @@ except ImportError:
16
16
  from functools import partial
17
17
  import hashlib
18
18
 
19
+ from ..config import get_option
19
20
 
20
- DEBUG = False
21
+
22
+ DEBUG = get_option('debug.connection')
21
23
  SCRAMBLE_LENGTH = 20
22
24
  sha1_new = partial(hashlib.new, 'sha1')
23
25
 
@@ -1,15 +1,16 @@
1
- # type: ignore
1
+ from typing import Dict
2
+ from typing import Optional
2
3
 
3
4
  MBLENGTH = {8: 1, 33: 3, 88: 2, 91: 2}
4
5
 
5
6
 
6
7
  class Charset:
7
8
 
8
- def __init__(self, id, name, collation, is_default):
9
+ def __init__(self, id: int, name: str, collation: str, is_default: str):
9
10
  self.id, self.name, self.collation = id, name, collation
10
11
  self.is_default = is_default == 'Yes'
11
12
 
12
- def __repr__(self):
13
+ def __repr__(self) -> str:
13
14
  return 'Charset(id=%s, name=%r, collation=%r)' % (
14
15
  self.id,
15
16
  self.name,
@@ -17,7 +18,7 @@ class Charset:
17
18
  )
18
19
 
19
20
  @property
20
- def encoding(self):
21
+ def encoding(self) -> str:
21
22
  name = self.name
22
23
  if name in ('utf8mb4', 'utf8mb3'):
23
24
  return 'utf8'
@@ -30,25 +31,25 @@ class Charset:
30
31
  return name
31
32
 
32
33
  @property
33
- def is_binary(self):
34
+ def is_binary(self) -> bool:
34
35
  return self.id == 63
35
36
 
36
37
 
37
38
  class Charsets:
38
39
 
39
- def __init__(self):
40
- self._by_id = {}
41
- self._by_name = {}
40
+ def __init__(self) -> None:
41
+ self._by_id: Dict[int, Charset] = {}
42
+ self._by_name: Dict[str, Charset] = {}
42
43
 
43
- def add(self, c):
44
+ def add(self, c: Charset) -> None:
44
45
  self._by_id[c.id] = c
45
46
  if c.is_default:
46
47
  self._by_name[c.name] = c
47
48
 
48
- def by_id(self, id):
49
+ def by_id(self, id: int) -> Charset:
49
50
  return self._by_id[id]
50
51
 
51
- def by_name(self, name):
52
+ def by_name(self, name: str) -> Optional[Charset]:
52
53
  return self._by_name.get(name.lower())
53
54
 
54
55
 
@@ -46,6 +46,7 @@ from .protocol import (
46
46
  LoadLocalPacketWrapper,
47
47
  )
48
48
  from . import err
49
+ from ..config import get_option
49
50
  from ..connection import Connection as BaseConnection
50
51
 
51
52
  try:
@@ -65,7 +66,7 @@ except (ImportError, KeyError):
65
66
  # KeyError occurs when there's no entry in OS database for a current user.
66
67
  DEFAULT_USER = None
67
68
 
68
- DEBUG = False
69
+ DEBUG = get_option('debug.connection')
69
70
 
70
71
  TEXT_TYPES = {
71
72
  FIELD_TYPE.BIT,
@@ -1051,7 +1052,7 @@ class Connection(BaseConnection):
1051
1052
  return data
1052
1053
 
1053
1054
  def _write_bytes(self, data):
1054
- if self._read_timeout is not None:
1055
+ if self._write_timeout is not None:
1055
1056
  self._sock.settimeout(self._write_timeout)
1056
1057
  try:
1057
1058
  self._sock.sendall(data)
@@ -1090,7 +1091,7 @@ class Connection(BaseConnection):
1090
1091
 
1091
1092
  """
1092
1093
  if not self._sock:
1093
- raise err.InterfaceError(0, '')
1094
+ raise err.InterfaceError(0, 'The connection has been closed')
1094
1095
 
1095
1096
  # If the last query was unbuffered, make sure it finishes before
1096
1097
  # sending new commands
@@ -1,4 +1,3 @@
1
- # type: ignore
2
1
  # https://dev.mysql.com/doc/internals/en/capability-flags.html#packet-Protocol::CapabilityFlags
3
2
  LONG_PASSWORD = 1
4
3
  FOUND_ROWS = 1 << 1
@@ -1,4 +1,3 @@
1
- # type: ignore
2
1
  COM_SLEEP = 0x00
3
2
  COM_QUIT = 0x01
4
3
  COM_INIT_DB = 0x02
@@ -1,5 +1,3 @@
1
- # flake8: noqa
2
- # type: ignore
3
1
  # errmsg.h
4
2
  CR_ERROR_FIRST = 2000
5
3
  CR_UNKNOWN_ERROR = 2000
@@ -1,4 +1,3 @@
1
- # type: ignore
2
1
  ERROR_FIRST = 1000
3
2
  HASHCHK = 1000
4
3
  NISAMCHK = 1001
@@ -1,4 +1,3 @@
1
- # type: ignore
2
1
  DECIMAL = 0
3
2
  TINY = 1
4
3
  SHORT = 2
@@ -1,4 +1,3 @@
1
- # type: ignore
2
1
  NOT_NULL = 1
3
2
  PRI_KEY = 2
4
3
  UNIQUE_KEY = 4
@@ -1,4 +1,3 @@
1
- # type: ignore
2
1
  SERVER_STATUS_IN_TRANS = 1
3
2
  SERVER_STATUS_AUTOCOMMIT = 2
4
3
  SERVER_MORE_RESULTS_EXISTS = 8
@@ -1,7 +1,12 @@
1
- # type: ignore
2
1
  import datetime
3
2
  import time
4
3
  from decimal import Decimal
4
+ from typing import Any
5
+ from typing import Callable
6
+ from typing import Dict
7
+ from typing import Optional
8
+ from typing import Tuple
9
+ from typing import Union
5
10
 
6
11
  from ..converters import converters as decoders
7
12
  from .err import ProgrammingError
@@ -26,7 +31,10 @@ except ImportError:
26
31
  has_pygeos = False
27
32
 
28
33
 
29
- def escape_item(val, charset, mapping=None):
34
+ Encoders = Dict[type, Callable[..., Union[str, Dict[str, str]]]]
35
+
36
+
37
+ def escape_item(val: Any, charset: str, mapping: Optional[Encoders] = None) -> str:
30
38
  if mapping is None:
31
39
  mapping = encoders
32
40
  encoder = mapping.get(type(val), None)
@@ -45,7 +53,11 @@ def escape_item(val, charset, mapping=None):
45
53
  return val
46
54
 
47
55
 
48
- def escape_dict(val, charset, mapping=None):
56
+ def escape_dict(
57
+ val: Dict[str, Any],
58
+ charset: str,
59
+ mapping: Optional[Encoders] = None,
60
+ ) -> Dict[str, str]:
49
61
  n = {}
50
62
  for k, v in val.items():
51
63
  quoted = escape_item(v, charset, mapping)
@@ -53,7 +65,11 @@ def escape_dict(val, charset, mapping=None):
53
65
  return n
54
66
 
55
67
 
56
- def escape_sequence(val, charset, mapping=None):
68
+ def escape_sequence(
69
+ val: Any,
70
+ charset: str,
71
+ mapping: Optional[Encoders] = None,
72
+ ) -> str:
57
73
  n = []
58
74
  for item in val:
59
75
  quoted = escape_item(item, charset, mapping)
@@ -61,28 +77,33 @@ def escape_sequence(val, charset, mapping=None):
61
77
  return '(' + ','.join(n) + ')'
62
78
 
63
79
 
64
- def escape_set(val, charset, mapping=None):
80
+ def escape_set(val: Any, charset: str, mapping: Optional[Encoders] = None) -> str:
65
81
  return ','.join([escape_item(x, charset, mapping) for x in val])
66
82
 
67
83
 
68
- def escape_bool(value, mapping=None):
84
+ def escape_bool(value: Any, mapping: Optional[Encoders] = None) -> str:
69
85
  return str(int(value))
70
86
 
71
87
 
72
- def escape_int(value, mapping=None):
88
+ def escape_int(value: Any, mapping: Optional[Encoders] = None) -> str:
73
89
  return str(value)
74
90
 
75
91
 
76
- def escape_float(value, mapping=None, nan_as_null=False, inf_as_null=False):
92
+ def escape_float(
93
+ value: Any,
94
+ mapping: Optional[Encoders] = None,
95
+ nan_as_null: bool = False,
96
+ inf_as_null: bool = False,
97
+ ) -> str:
77
98
  s = repr(value)
78
99
  if s == 'nan':
79
100
  if nan_as_null:
80
101
  return 'NULL'
81
- raise ProgrammingError('%s can not be used with SingleStoreDB' % s)
102
+ raise ProgrammingError(0, '%s can not be used with SingleStoreDB' % s)
82
103
  if s == 'inf':
83
104
  if inf_as_null:
84
105
  return 'NULL'
85
- raise ProgrammingError('%s can not be used with SingleStoreDB' % s)
106
+ raise ProgrammingError(0, '%s can not be used with SingleStoreDB' % s)
86
107
  if 'e' not in s:
87
108
  s += 'e0'
88
109
  return s
@@ -98,7 +119,7 @@ _escape_table[ord('"')] = '\\"'
98
119
  _escape_table[ord("'")] = "\\'"
99
120
 
100
121
 
101
- def escape_string(value, mapping=None):
122
+ def escape_string(value: str, mapping: Optional[Encoders] = None) -> str:
102
123
  """
103
124
  Escapes *value* without adding quote.
104
125
 
@@ -108,23 +129,23 @@ def escape_string(value, mapping=None):
108
129
  return value.translate(_escape_table)
109
130
 
110
131
 
111
- def escape_bytes_prefixed(value, mapping=None):
132
+ def escape_bytes_prefixed(value: bytes, mapping: Optional[Encoders] = None) -> str:
112
133
  return "_binary X'{}'".format(value.hex())
113
134
 
114
135
 
115
- def escape_bytes(value, mapping=None):
136
+ def escape_bytes(value: bytes, mapping: Optional[Encoders] = None) -> str:
116
137
  return "X'{}'".format(value.hex())
117
138
 
118
139
 
119
- def escape_str(value, mapping=None):
140
+ def escape_str(value: str, mapping: Optional[Encoders] = None) -> str:
120
141
  return "'{}'".format(escape_string(str(value), mapping))
121
142
 
122
143
 
123
- def escape_None(value, mapping=None):
144
+ def escape_None(value: str, mapping: Optional[Encoders] = None) -> str:
124
145
  return 'NULL'
125
146
 
126
147
 
127
- def escape_timedelta(obj, mapping=None):
148
+ def escape_timedelta(obj: datetime.timedelta, mapping: Optional[Encoders] = None) -> str:
128
149
  seconds = int(obj.seconds) % 60
129
150
  minutes = int(obj.seconds // 60) % 60
130
151
  hours = int(obj.seconds // 3600) % 24 + int(obj.days) * 24
@@ -135,7 +156,7 @@ def escape_timedelta(obj, mapping=None):
135
156
  return fmt.format(hours, minutes, seconds, obj.microseconds)
136
157
 
137
158
 
138
- def escape_time(obj, mapping=None):
159
+ def escape_time(obj: datetime.time, mapping: Optional[Encoders] = None) -> str:
139
160
  if obj.microsecond:
140
161
  fmt = "'{0.hour:02}:{0.minute:02}:{0.second:02}.{0.microsecond:06}'"
141
162
  else:
@@ -143,7 +164,7 @@ def escape_time(obj, mapping=None):
143
164
  return fmt.format(obj)
144
165
 
145
166
 
146
- def escape_datetime(obj, mapping=None):
167
+ def escape_datetime(obj: datetime.datetime, mapping: Optional[Encoders] = None) -> str:
147
168
  if obj.microsecond:
148
169
  fmt = "'{0.year:04}-{0.month:02}-{0.day:02} " \
149
170
  "{0.hour:02}:{0.minute:02}:{0.second:02}.{0.microsecond:06}'"
@@ -153,20 +174,20 @@ def escape_datetime(obj, mapping=None):
153
174
  return fmt.format(obj)
154
175
 
155
176
 
156
- def escape_date(obj, mapping=None):
177
+ def escape_date(obj: datetime.date, mapping: Optional[Encoders] = None) -> str:
157
178
  fmt = "'{0.year:04}-{0.month:02}-{0.day:02}'"
158
179
  return fmt.format(obj)
159
180
 
160
181
 
161
- def escape_struct_time(obj, mapping=None):
182
+ def escape_struct_time(obj: Tuple[Any, ...], mapping: Optional[Encoders] = None) -> str:
162
183
  return escape_datetime(datetime.datetime(*obj[:6]))
163
184
 
164
185
 
165
- def Decimal2Literal(o, d):
186
+ def Decimal2Literal(o: Any, d: Any) -> str:
166
187
  return format(o, 'f')
167
188
 
168
189
 
169
- def through(x):
190
+ def through(x: Any) -> Any:
170
191
  return x
171
192
 
172
193
 
@@ -179,7 +200,7 @@ def through(x):
179
200
  convert_bit = through
180
201
 
181
202
 
182
- encoders = {
203
+ encoders: Encoders = {
183
204
  bool: escape_bool,
184
205
  int: escape_int,
185
206
  float: escape_float,
@@ -201,7 +222,7 @@ encoders = {
201
222
 
202
223
  if has_numpy:
203
224
 
204
- def escape_numpy(value, mapping=None):
225
+ def escape_numpy(value: Any, mapping: Optional[Encoders] = None) -> str:
205
226
  """Convert numpy arrays to vectors of bytes."""
206
227
  return escape_bytes(value.tobytes(), mapping=mapping)
207
228
 
@@ -225,7 +246,7 @@ if has_numpy:
225
246
 
226
247
  if has_shapely:
227
248
 
228
- def escape_shapely(value, mapping=None):
249
+ def escape_shapely(value: Any, mapping: Optional[Encoders] = None) -> str:
229
250
  """Convert shapely geo objects."""
230
251
  return escape_str(shapely.wkt.dumps(value), mapping=mapping)
231
252
 
@@ -235,7 +256,7 @@ if has_shapely:
235
256
 
236
257
  if has_pygeos:
237
258
 
238
- def escape_pygeos(value, mapping=None):
259
+ def escape_pygeos(value: Any, mapping: Optional[Encoders] = None) -> str:
239
260
  """Convert pygeos objects."""
240
261
  return escape_str(pygeos.io.to_wkt(value), mapping=mapping)
241
262
 
@@ -243,8 +264,8 @@ if has_pygeos:
243
264
 
244
265
 
245
266
  # for MySQLdb compatibility
246
- conversions = encoders.copy()
247
- conversions.update(decoders)
267
+ conversions = encoders.copy() # type: ignore
268
+ conversions.update(decoders) # type: ignore
248
269
  Thing2Literal = escape_str
249
270
 
250
271
  # Run doctests with `pytest --doctest-modules pymysql/converters.py`
@@ -1,5 +1,5 @@
1
- # type: ignore
2
1
  import struct
2
+ from typing import Any
3
3
 
4
4
  from ..exceptions import DatabaseError # noqa: F401
5
5
  from ..exceptions import DataError # noqa: F401
@@ -18,7 +18,7 @@ from .constants import ER
18
18
  error_map = {}
19
19
 
20
20
 
21
- def _map_error(exc, *errors):
21
+ def _map_error(exc: Any, *errors: int) -> None:
22
22
  for error in errors:
23
23
  error_map[error] = exc
24
24
 
@@ -83,7 +83,7 @@ _map_error(
83
83
  del _map_error, ER
84
84
 
85
85
 
86
- def raise_mysql_exception(data):
86
+ def raise_mysql_exception(data: bytes) -> Exception:
87
87
  errno = struct.unpack('<h', data[1:3])[0]
88
88
  errval = data[9:].decode('utf-8', 'replace')
89
89
  errorclass = error_map.get(errno)
@@ -1,20 +1,20 @@
1
- # type: ignore
2
1
  import configparser
2
+ from typing import Any
3
3
 
4
4
 
5
5
  class Parser(configparser.RawConfigParser):
6
6
 
7
- def __init__(self, **kwargs):
7
+ def __init__(self, **kwargs: Any) -> None:
8
8
  kwargs['allow_no_value'] = True
9
9
  configparser.RawConfigParser.__init__(self, **kwargs)
10
10
 
11
- def __remove_quotes(self, value):
11
+ def __remove_quotes(self, value: str) -> str:
12
12
  quotes = ["'", '"']
13
13
  for quote in quotes:
14
14
  if len(value) >= 2 and value[0] == value[-1] == quote:
15
15
  return value[1:-1]
16
16
  return value
17
17
 
18
- def get(self, section, option):
18
+ def get(self, section: str, option: str) -> str: # type: ignore
19
19
  value = configparser.RawConfigParser.get(self, section, option)
20
20
  return self.__remove_quotes(value)
@@ -5,13 +5,14 @@ import struct
5
5
  import sys
6
6
 
7
7
  from . import err
8
+ from ..config import get_option
8
9
  from ..utils.results import Description
9
10
  from .charset import MBLENGTH
10
11
  from .constants import FIELD_TYPE
11
12
  from .constants import SERVER_STATUS
12
13
 
13
14
 
14
- DEBUG = False
15
+ DEBUG = get_option('debug.connection')
15
16
 
16
17
  NULL_COLUMN = 251
17
18
  UNSIGNED_CHAR_COLUMN = 251
@@ -1,4 +1,3 @@
1
- # type: ignore
2
1
  from datetime import date
3
2
  from datetime import datetime
4
3
  from datetime import time
@@ -12,13 +11,13 @@ TimeDelta = timedelta
12
11
  Timestamp = datetime
13
12
 
14
13
 
15
- def DateFromTicks(ticks):
14
+ def DateFromTicks(ticks: int) -> date:
16
15
  return date(*localtime(ticks)[:3])
17
16
 
18
17
 
19
- def TimeFromTicks(ticks):
18
+ def TimeFromTicks(ticks: int) -> time:
20
19
  return time(*localtime(ticks)[3:6])
21
20
 
22
21
 
23
- def TimestampFromTicks(ticks):
22
+ def TimestampFromTicks(ticks: int) -> datetime:
24
23
  return datetime(*localtime(ticks)[:6])
@@ -0,0 +1 @@
1
+ -- Nearly empty file for Stages test