mysqlx-connector-python 9.5.0__cp314-cp314-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.
Files changed (42) hide show
  1. _mysqlxpb.cp314-win_amd64.pyd +0 -0
  2. mysqlx/__init__.py +136 -0
  3. mysqlx/authentication.py +186 -0
  4. mysqlx/charsets.py +620 -0
  5. mysqlx/connection.py +3374 -0
  6. mysqlx/constants.py +240 -0
  7. mysqlx/crud.py +776 -0
  8. mysqlx/dbdoc.py +120 -0
  9. mysqlx/errorcode.py +1877 -0
  10. mysqlx/errors.py +257 -0
  11. mysqlx/expr.py +1366 -0
  12. mysqlx/helpers.py +234 -0
  13. mysqlx/locales/__init__.py +80 -0
  14. mysqlx/locales/eng/__init__.py +30 -0
  15. mysqlx/locales/eng/client_error.py +152 -0
  16. mysqlx/logger.py +33 -0
  17. mysqlx/protobuf/__init__.py +627 -0
  18. mysqlx/protobuf/mysqlx_connection_pb2.py +74 -0
  19. mysqlx/protobuf/mysqlx_crud_pb2.py +108 -0
  20. mysqlx/protobuf/mysqlx_cursor_pb2.py +68 -0
  21. mysqlx/protobuf/mysqlx_datatypes_pb2.py +75 -0
  22. mysqlx/protobuf/mysqlx_expect_pb2.py +69 -0
  23. mysqlx/protobuf/mysqlx_expr_pb2.py +81 -0
  24. mysqlx/protobuf/mysqlx_notice_pb2.py +81 -0
  25. mysqlx/protobuf/mysqlx_pb2.py +71 -0
  26. mysqlx/protobuf/mysqlx_prepare_pb2.py +73 -0
  27. mysqlx/protobuf/mysqlx_resultset_pb2.py +75 -0
  28. mysqlx/protobuf/mysqlx_session_pb2.py +67 -0
  29. mysqlx/protobuf/mysqlx_sql_pb2.py +63 -0
  30. mysqlx/protocol.py +1218 -0
  31. mysqlx/py.typed +27 -0
  32. mysqlx/result.py +1177 -0
  33. mysqlx/statement.py +1542 -0
  34. mysqlx/tls_ciphers.py +169 -0
  35. mysqlx/types.py +120 -0
  36. mysqlx/utils.py +178 -0
  37. mysqlx/version.py +46 -0
  38. mysqlx_connector_python-9.5.0.dist-info/METADATA +217 -0
  39. mysqlx_connector_python-9.5.0.dist-info/RECORD +42 -0
  40. mysqlx_connector_python-9.5.0.dist-info/WHEEL +5 -0
  41. mysqlx_connector_python-9.5.0.dist-info/licenses/LICENSE.txt +8125 -0
  42. mysqlx_connector_python-9.5.0.dist-info/top_level.txt +2 -0
Binary file
mysqlx/__init__.py ADDED
@@ -0,0 +1,136 @@
1
+ # Copyright (c) 2016, 2024, Oracle and/or its affiliates.
2
+ #
3
+ # This program is free software; you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License, version 2.0, as
5
+ # published by the Free Software Foundation.
6
+ #
7
+ # This program is designed to work with certain software (including
8
+ # but not limited to OpenSSL) that is licensed under separate terms,
9
+ # as designated in a particular file or component or in included license
10
+ # documentation. The authors of MySQL hereby grant you an
11
+ # additional permission to link the program and your derivative works
12
+ # with the separately licensed software that they have either included with
13
+ # the program or referenced in the documentation.
14
+ #
15
+ # Without limiting anything contained in the foregoing, this file,
16
+ # which is part of MySQL Connector/Python, is also subject to the
17
+ # Universal FOSS Exception, version 1.0, a copy of which can be found at
18
+ # http://oss.oracle.com/licenses/universal-foss-exception.
19
+ #
20
+ # This program is distributed in the hope that it will be useful, but
21
+ # WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23
+ # See the GNU General Public License, version 2.0, for more details.
24
+ #
25
+ # You should have received a copy of the GNU General Public License
26
+ # along with this program; if not, write to the Free Software Foundation, Inc.,
27
+ # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28
+
29
+ """MySQL X DevAPI Python implementation."""
30
+
31
+ from . import version
32
+ from .connection import Client, Session, get_client, get_session
33
+ from .constants import Auth, Compression, LockContention, SSLMode
34
+ from .crud import Collection, Schema, Table, View
35
+ from .dbdoc import DbDoc
36
+ from .errors import ( # pylint: disable=redefined-builtin
37
+ DatabaseError,
38
+ DataError,
39
+ Error,
40
+ IntegrityError,
41
+ InterfaceError,
42
+ InternalError,
43
+ NotSupportedError,
44
+ OperationalError,
45
+ PoolError,
46
+ ProgrammingError,
47
+ TimeoutError,
48
+ )
49
+ from .expr import ExprParser as expr
50
+ from .result import (
51
+ BufferingResult,
52
+ Column,
53
+ ColumnType,
54
+ DocResult,
55
+ Result,
56
+ Row,
57
+ RowResult,
58
+ SqlResult,
59
+ )
60
+ from .statement import (
61
+ AddStatement,
62
+ CreateCollectionIndexStatement,
63
+ DeleteStatement,
64
+ Expr,
65
+ FilterableStatement,
66
+ FindStatement,
67
+ InsertStatement,
68
+ ModifyStatement,
69
+ ReadStatement,
70
+ RemoveStatement,
71
+ SelectStatement,
72
+ SqlStatement,
73
+ Statement,
74
+ UpdateStatement,
75
+ WriteStatement,
76
+ )
77
+
78
+ __version_info__ = version.VERSION
79
+ __version__ = version.VERSION_TEXT
80
+
81
+ __all__ = [
82
+ # mysqlx.connection
83
+ "Client",
84
+ "Session",
85
+ "get_client",
86
+ "get_session",
87
+ "expr",
88
+ # mysqlx.constants
89
+ "Auth",
90
+ "Compression",
91
+ "LockContention",
92
+ "SSLMode",
93
+ # mysqlx.crud
94
+ "Schema",
95
+ "Collection",
96
+ "Table",
97
+ "View",
98
+ # mysqlx.errors
99
+ "Error",
100
+ "InterfaceError",
101
+ "DatabaseError",
102
+ "NotSupportedError",
103
+ "DataError",
104
+ "IntegrityError",
105
+ "ProgrammingError",
106
+ "OperationalError",
107
+ "InternalError",
108
+ "PoolError",
109
+ "TimeoutError",
110
+ # mysqlx.result
111
+ "Column",
112
+ "Row",
113
+ "Result",
114
+ "BufferingResult",
115
+ "RowResult",
116
+ "SqlResult",
117
+ "DocResult",
118
+ "ColumnType",
119
+ # mysqlx.statement
120
+ "DbDoc",
121
+ "Statement",
122
+ "FilterableStatement",
123
+ "SqlStatement",
124
+ "FindStatement",
125
+ "AddStatement",
126
+ "RemoveStatement",
127
+ "ModifyStatement",
128
+ "SelectStatement",
129
+ "InsertStatement",
130
+ "DeleteStatement",
131
+ "UpdateStatement",
132
+ "ReadStatement",
133
+ "WriteStatement",
134
+ "CreateCollectionIndexStatement",
135
+ "Expr",
136
+ ]
@@ -0,0 +1,186 @@
1
+ # Copyright (c) 2016, 2024, Oracle and/or its affiliates.
2
+ #
3
+ # This program is free software; you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License, version 2.0, as
5
+ # published by the Free Software Foundation.
6
+ #
7
+ # This program is designed to work with certain software (including
8
+ # but not limited to OpenSSL) that is licensed under separate terms,
9
+ # as designated in a particular file or component or in included license
10
+ # documentation. The authors of MySQL hereby grant you an
11
+ # additional permission to link the program and your derivative works
12
+ # with the separately licensed software that they have either included with
13
+ # the program or referenced in the documentation.
14
+ #
15
+ # Without limiting anything contained in the foregoing, this file,
16
+ # which is part of MySQL Connector/Python, is also subject to the
17
+ # Universal FOSS Exception, version 1.0, a copy of which can be found at
18
+ # http://oss.oracle.com/licenses/universal-foss-exception.
19
+ #
20
+ # This program is distributed in the hope that it will be useful, but
21
+ # WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23
+ # See the GNU General Public License, version 2.0, for more details.
24
+ #
25
+ # You should have received a copy of the GNU General Public License
26
+ # along with this program; if not, write to the Free Software Foundation, Inc.,
27
+ # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28
+
29
+ """Implementation of MySQL Authentication Plugin."""
30
+
31
+ import hashlib
32
+ import struct
33
+
34
+ from typing import Optional
35
+
36
+ from .helpers import hexlify
37
+
38
+
39
+ def xor_string(hash1: bytes, hash2: bytes, hash_size: int) -> bytes:
40
+ """Encrypt/Decrypt function used for password encryption in
41
+ authentication, using a simple XOR.
42
+
43
+ Args:
44
+ hash1 (str): The first hash.
45
+ hash2 (str): The second hash.
46
+
47
+ Returns:
48
+ str: A string with the xor applied.
49
+ """
50
+ xored = [h1 ^ h2 for (h1, h2) in zip(hash1, hash2)]
51
+ return struct.pack(f"{hash_size}B", *xored)
52
+
53
+
54
+ class BaseAuthPlugin:
55
+ """Base class for implementing the authentication plugins."""
56
+
57
+ def __init__(self, username: Optional[str] = None, password: Optional[str] = None):
58
+ self._username: Optional[str] = username
59
+ self._password: Optional[str] = password
60
+
61
+ def name(self) -> str:
62
+ """Returns the plugin name.
63
+
64
+ Returns:
65
+ str: The plugin name.
66
+ """
67
+ raise NotImplementedError
68
+
69
+ def auth_name(self) -> str:
70
+ """Returns the authentication name.
71
+
72
+ Returns:
73
+ str: The authentication name.
74
+ """
75
+ raise NotImplementedError
76
+
77
+
78
+ class MySQL41AuthPlugin(BaseAuthPlugin):
79
+ """Class implementing the MySQL Native Password authentication plugin."""
80
+
81
+ def name(self) -> str:
82
+ """Returns the plugin name.
83
+
84
+ Returns:
85
+ str: The plugin name.
86
+ """
87
+ return "MySQL 4.1 Authentication Plugin"
88
+
89
+ def auth_name(self) -> str:
90
+ """Returns the authentication name.
91
+
92
+ Returns:
93
+ str: The authentication name.
94
+ """
95
+ return "MYSQL41"
96
+
97
+ def auth_data(self, data: bytes) -> str:
98
+ """Hashing for MySQL 4.1 authentication.
99
+
100
+ Args:
101
+ data (bytes): The authentication data.
102
+
103
+ Returns:
104
+ str: The authentication response.
105
+ """
106
+ if self._password:
107
+ password = (
108
+ self._password.encode("utf-8")
109
+ if isinstance(self._password, str)
110
+ else self._password
111
+ )
112
+ hash1 = hashlib.sha1(password).digest()
113
+ hash2 = hashlib.sha1(hash1).digest()
114
+ xored = xor_string(hash1, hashlib.sha1(data + hash2).digest(), 20)
115
+ return f"\0{self._username}\0*{hexlify(xored)}\0"
116
+ return f"\0{self._username}\0"
117
+
118
+
119
+ class PlainAuthPlugin(BaseAuthPlugin):
120
+ """Class implementing the MySQL Plain authentication plugin."""
121
+
122
+ def name(self) -> str:
123
+ """Returns the plugin name.
124
+
125
+ Returns:
126
+ str: The plugin name.
127
+ """
128
+ return "Plain Authentication Plugin"
129
+
130
+ def auth_name(self) -> str:
131
+ """Returns the authentication name.
132
+
133
+ Returns:
134
+ str: The authentication name.
135
+ """
136
+ return "PLAIN"
137
+
138
+ def auth_data(self) -> str:
139
+ """Returns the authentication data.
140
+
141
+ Returns:
142
+ str: The authentication data.
143
+ """
144
+ return f"\0{self._username}\0{self._password}"
145
+
146
+
147
+ class Sha256MemoryAuthPlugin(BaseAuthPlugin):
148
+ """Class implementing the SHA256_MEMORY authentication plugin."""
149
+
150
+ def name(self) -> str:
151
+ """Returns the plugin name.
152
+
153
+ Returns:
154
+ str: The plugin name.
155
+ """
156
+ return "SHA256_MEMORY Authentication Plugin"
157
+
158
+ def auth_name(self) -> str:
159
+ """Returns the authentication name.
160
+
161
+ Returns:
162
+ str: The authentication name.
163
+ """
164
+ return "SHA256_MEMORY"
165
+
166
+ def auth_data(self, data: bytes) -> str:
167
+ """Hashing for SHA256_MEMORY authentication.
168
+
169
+ The scramble is of the form:
170
+ SHA256(SHA256(SHA256(PASSWORD)),NONCE) XOR SHA256(PASSWORD)
171
+
172
+ Args:
173
+ data (bytes): The authentication data.
174
+
175
+ Returns:
176
+ str: The authentication response.
177
+ """
178
+ password = (
179
+ self._password.encode("utf-8")
180
+ if isinstance(self._password, str)
181
+ else self._password
182
+ )
183
+ hash1 = hashlib.sha256(password).digest()
184
+ hash2 = hashlib.sha256(hashlib.sha256(hash1).digest() + data).digest()
185
+ xored = xor_string(hash2, hash1, 32)
186
+ return f"\0{self._username}\0{hexlify(xored)}"