mysqlx-connector-python 8.3.0__py2.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.
- mysqlx/__init__.py +136 -0
- mysqlx/authentication.py +186 -0
- mysqlx/charsets.py +620 -0
- mysqlx/connection.py +3364 -0
- mysqlx/constants.py +297 -0
- mysqlx/crud.py +776 -0
- mysqlx/dbdoc.py +120 -0
- mysqlx/errorcode.py +1877 -0
- mysqlx/errors.py +257 -0
- mysqlx/expr.py +1366 -0
- mysqlx/helpers.py +234 -0
- mysqlx/locales/__init__.py +80 -0
- mysqlx/locales/eng/__init__.py +30 -0
- mysqlx/locales/eng/client_error.py +152 -0
- mysqlx/logger.py +33 -0
- mysqlx/protobuf/__init__.py +627 -0
- mysqlx/protobuf/mysqlx_connection_pb2.py +74 -0
- mysqlx/protobuf/mysqlx_crud_pb2.py +108 -0
- mysqlx/protobuf/mysqlx_cursor_pb2.py +68 -0
- mysqlx/protobuf/mysqlx_datatypes_pb2.py +75 -0
- mysqlx/protobuf/mysqlx_expect_pb2.py +69 -0
- mysqlx/protobuf/mysqlx_expr_pb2.py +81 -0
- mysqlx/protobuf/mysqlx_notice_pb2.py +81 -0
- mysqlx/protobuf/mysqlx_pb2.py +71 -0
- mysqlx/protobuf/mysqlx_prepare_pb2.py +73 -0
- mysqlx/protobuf/mysqlx_resultset_pb2.py +75 -0
- mysqlx/protobuf/mysqlx_session_pb2.py +67 -0
- mysqlx/protobuf/mysqlx_sql_pb2.py +63 -0
- mysqlx/protocol.py +1214 -0
- mysqlx/py.typed +0 -0
- mysqlx/result.py +1177 -0
- mysqlx/statement.py +1542 -0
- mysqlx/types.py +92 -0
- mysqlx/utils.py +136 -0
- mysqlx/version.py +46 -0
- mysqlx_connector_python-8.3.0.dist-info/LICENSE.txt +4211 -0
- mysqlx_connector_python-8.3.0.dist-info/METADATA +43 -0
- mysqlx_connector_python-8.3.0.dist-info/RECORD +40 -0
- mysqlx_connector_python-8.3.0.dist-info/WHEEL +6 -0
- mysqlx_connector_python-8.3.0.dist-info/top_level.txt +1 -0
mysqlx/types.py
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Type hint aliases hub
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import typing
|
|
6
|
+
|
|
7
|
+
from datetime import datetime, timedelta
|
|
8
|
+
from decimal import Decimal
|
|
9
|
+
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Type, Union
|
|
10
|
+
|
|
11
|
+
if hasattr(typing, "TypeAlias"):
|
|
12
|
+
# pylint: disable=no-name-in-module
|
|
13
|
+
from typing import TypeAlias # type: ignore[attr-defined]
|
|
14
|
+
else:
|
|
15
|
+
try:
|
|
16
|
+
from typing_extensions import TypeAlias
|
|
17
|
+
except ModuleNotFoundError:
|
|
18
|
+
# pylint: disable=reimported
|
|
19
|
+
from typing import Any as TypeAlias
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
if TYPE_CHECKING:
|
|
23
|
+
from google.protobuf.message import Message as ProtoMessage
|
|
24
|
+
|
|
25
|
+
# pylint: disable=redefined-builtin
|
|
26
|
+
from .connection import Connection, Session, SocketStream
|
|
27
|
+
from .crud import DatabaseObject, Schema
|
|
28
|
+
from .dbdoc import DbDoc
|
|
29
|
+
from .errors import (
|
|
30
|
+
DatabaseError,
|
|
31
|
+
DataError,
|
|
32
|
+
Error,
|
|
33
|
+
IntegrityError,
|
|
34
|
+
InterfaceError,
|
|
35
|
+
InternalError,
|
|
36
|
+
NotSupportedError,
|
|
37
|
+
OperationalError,
|
|
38
|
+
PoolError,
|
|
39
|
+
ProgrammingError,
|
|
40
|
+
TimeoutError,
|
|
41
|
+
)
|
|
42
|
+
from .expr import ExprParser
|
|
43
|
+
from .protobuf import Message as XdevMessage
|
|
44
|
+
from .result import BaseResult, Column
|
|
45
|
+
from .statement import Statement
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
StrOrBytes = Union[str, bytes]
|
|
49
|
+
|
|
50
|
+
BuildScalarTypes = Optional[Union[str, bytes, bool, int, float]]
|
|
51
|
+
BuildExprTypes = Union[
|
|
52
|
+
"XdevMessage", "ExprParser", Dict[str, Any], "DbDoc", List, Tuple, BuildScalarTypes
|
|
53
|
+
]
|
|
54
|
+
ColumnType: TypeAlias = "Column"
|
|
55
|
+
ConnectionType: TypeAlias = "Connection"
|
|
56
|
+
DatabaseTargetType: TypeAlias = "DatabaseObject"
|
|
57
|
+
ErrorClassTypes = Union[
|
|
58
|
+
Type["Error"],
|
|
59
|
+
Type["InterfaceError"],
|
|
60
|
+
Type["DatabaseError"],
|
|
61
|
+
Type["InternalError"],
|
|
62
|
+
Type["OperationalError"],
|
|
63
|
+
Type["ProgrammingError"],
|
|
64
|
+
Type["IntegrityError"],
|
|
65
|
+
Type["DataError"],
|
|
66
|
+
Type["NotSupportedError"],
|
|
67
|
+
Type["PoolError"],
|
|
68
|
+
Type["TimeoutError"],
|
|
69
|
+
]
|
|
70
|
+
ErrorTypes = Union[
|
|
71
|
+
"Error",
|
|
72
|
+
"InterfaceError",
|
|
73
|
+
"DatabaseError",
|
|
74
|
+
"InternalError",
|
|
75
|
+
"OperationalError",
|
|
76
|
+
"ProgrammingError",
|
|
77
|
+
"IntegrityError",
|
|
78
|
+
"DataError",
|
|
79
|
+
"NotSupportedError",
|
|
80
|
+
"PoolError",
|
|
81
|
+
"TimeoutError",
|
|
82
|
+
]
|
|
83
|
+
EscapeTypes = Optional[Union[int, float, Decimal, StrOrBytes]]
|
|
84
|
+
FieldTypes = Optional[Union[int, float, str, bytes, Decimal, datetime, timedelta]]
|
|
85
|
+
MessageType: TypeAlias = "XdevMessage"
|
|
86
|
+
ProtobufMessageType: TypeAlias = "ProtoMessage"
|
|
87
|
+
ProtobufMessageCextType = Dict[str, Any]
|
|
88
|
+
ResultBaseType: TypeAlias = "BaseResult"
|
|
89
|
+
SchemaType: TypeAlias = "Schema"
|
|
90
|
+
SessionType: TypeAlias = "Session"
|
|
91
|
+
SocketType: TypeAlias = "SocketStream"
|
|
92
|
+
StatementType: TypeAlias = "Statement"
|
mysqlx/utils.py
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# Copyright (c) 2009, 2023, 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 also distributed 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 included with
|
|
13
|
+
# MySQL.
|
|
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
|
+
"""Utilities."""
|
|
30
|
+
|
|
31
|
+
import os
|
|
32
|
+
import subprocess
|
|
33
|
+
import sys
|
|
34
|
+
|
|
35
|
+
from typing import Dict, Optional, Tuple
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _parse_os_release() -> Dict[str, str]:
|
|
39
|
+
"""Parse the contents of /etc/os-release file.
|
|
40
|
+
|
|
41
|
+
Returns:
|
|
42
|
+
A dictionary containing release information.
|
|
43
|
+
"""
|
|
44
|
+
distro: Dict[str, str] = {}
|
|
45
|
+
os_release_file = os.path.join("/etc", "os-release")
|
|
46
|
+
if not os.path.exists(os_release_file):
|
|
47
|
+
return distro
|
|
48
|
+
with open(os_release_file, encoding="utf-8") as file_obj:
|
|
49
|
+
for line in file_obj:
|
|
50
|
+
key_value = line.split("=")
|
|
51
|
+
if len(key_value) != 2:
|
|
52
|
+
continue
|
|
53
|
+
key = key_value[0].lower()
|
|
54
|
+
value = key_value[1].rstrip("\n").strip('"')
|
|
55
|
+
distro[key] = value
|
|
56
|
+
return distro
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _parse_lsb_release() -> Dict[str, str]:
|
|
60
|
+
"""Parse the contents of /etc/lsb-release file.
|
|
61
|
+
|
|
62
|
+
Returns:
|
|
63
|
+
A dictionary containing release information.
|
|
64
|
+
"""
|
|
65
|
+
distro = {}
|
|
66
|
+
lsb_release_file = os.path.join("/etc", "lsb-release")
|
|
67
|
+
if os.path.exists(lsb_release_file):
|
|
68
|
+
with open(lsb_release_file, encoding="utf-8") as file_obj:
|
|
69
|
+
for line in file_obj:
|
|
70
|
+
key_value = line.split("=")
|
|
71
|
+
if len(key_value) != 2:
|
|
72
|
+
continue
|
|
73
|
+
key = key_value[0].lower()
|
|
74
|
+
value = key_value[1].rstrip("\n").strip('"')
|
|
75
|
+
distro[key] = value
|
|
76
|
+
return distro
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def _parse_lsb_release_command() -> Optional[Dict[str, str]]:
|
|
80
|
+
"""Parse the output of the lsb_release command.
|
|
81
|
+
|
|
82
|
+
Returns:
|
|
83
|
+
A dictionary containing release information.
|
|
84
|
+
"""
|
|
85
|
+
distro = {}
|
|
86
|
+
with open(os.devnull, "w", encoding="utf-8") as devnull:
|
|
87
|
+
try:
|
|
88
|
+
stdout = subprocess.check_output(("lsb_release", "-a"), stderr=devnull)
|
|
89
|
+
except OSError:
|
|
90
|
+
return None
|
|
91
|
+
lines = stdout.decode(sys.getfilesystemencoding()).splitlines()
|
|
92
|
+
for line in lines:
|
|
93
|
+
key_value = line.split(":")
|
|
94
|
+
if len(key_value) != 2:
|
|
95
|
+
continue
|
|
96
|
+
key = key_value[0].replace(" ", "_").lower()
|
|
97
|
+
value = key_value[1].strip("\t")
|
|
98
|
+
distro[key] = value
|
|
99
|
+
return distro
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def linux_distribution() -> Tuple[str, str, str]:
|
|
103
|
+
"""Tries to determine the name of the Linux OS distribution name.
|
|
104
|
+
|
|
105
|
+
First tries to get information from ``/etc/os-release`` file.
|
|
106
|
+
If fails, tries to get the information of ``/etc/lsb-release`` file.
|
|
107
|
+
And finally the information of ``lsb-release`` command.
|
|
108
|
+
|
|
109
|
+
Returns:
|
|
110
|
+
A tuple with (`name`, `version`, `codename`)
|
|
111
|
+
"""
|
|
112
|
+
distro: Optional[Dict[str, str]] = _parse_lsb_release()
|
|
113
|
+
if distro:
|
|
114
|
+
return (
|
|
115
|
+
distro.get("distrib_id", ""),
|
|
116
|
+
distro.get("distrib_release", ""),
|
|
117
|
+
distro.get("distrib_codename", ""),
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
distro = _parse_lsb_release_command()
|
|
121
|
+
if distro:
|
|
122
|
+
return (
|
|
123
|
+
distro.get("distributor_id", ""),
|
|
124
|
+
distro.get("release", ""),
|
|
125
|
+
distro.get("codename", ""),
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
distro = _parse_os_release()
|
|
129
|
+
if distro:
|
|
130
|
+
return (
|
|
131
|
+
distro.get("name", ""),
|
|
132
|
+
distro.get("version_id", ""),
|
|
133
|
+
distro.get("version_codename", ""),
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
return ("", "", "")
|
mysqlx/version.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
|
|
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 also distributed 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 included with
|
|
13
|
+
# MySQL.
|
|
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 Connector/Python version information
|
|
30
|
+
|
|
31
|
+
The file version.py gets installed and is available after installation
|
|
32
|
+
as mysqlx.version.
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
VERSION = (8, 3, 0, "", 1)
|
|
36
|
+
|
|
37
|
+
# pylint: disable=consider-using-f-string
|
|
38
|
+
if VERSION[3] and VERSION[4]:
|
|
39
|
+
VERSION_TEXT = "{0}.{1}.{2}{3}{4}".format(*VERSION)
|
|
40
|
+
else:
|
|
41
|
+
VERSION_TEXT = "{0}.{1}.{2}".format(*VERSION[0:3])
|
|
42
|
+
# pylint: enable=consider-using-f-string
|
|
43
|
+
|
|
44
|
+
VERSION_EXTRA = ""
|
|
45
|
+
LICENSE = "GPLv2 with FOSS License Exception"
|
|
46
|
+
EDITION = "" # Added in package names, after the version
|