You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The tests can be configured to be launched using an external server or bootstrapping it. The former is preferred (we'll assume so moving forward).
89
89
90
-
As you can see, there are several parameters that can be injected into the ``unittests`` module. The parameters shown above are optional, or a must if you want to run the tests with the *C extension* enabled for the ``mysql.connector`` module.
90
+
As you can see, there are several parameters that can be injected into the ``unittests`` module. The parameters shown above are optional, or a must if you want to run the tests with the *C extension* enabled for the ``mysql.connector`` and ``mysqlx`` modules.
91
91
92
-
The ``with-mysql-capi`` flag is needed to build the `C extension` of ``mysql.connector``.
92
+
The ``with-mysql-capi`` flag is needed to build the `C extension` of ``mysql.connector``, the remaining ones are needed to build it for ``mysqlx``.
93
93
94
94
Additionally, there are parameters or flags that can be provided to set values to be used when connecting to the server:
95
95
96
96
* **user**: the value stored by the environment variable ``MYSQL_USER`` is used (if set), otherwise, ``root`` is used by default.
97
97
* **password**: the value of ``MYSQL_PASSWORD`` is used (if set), otherwise, ``empty_string`` is used by default.
98
98
* **port**: the value of ``MYSQL_PORT`` is used (if set), otherwise, ``3306`` is used by default.
99
+
* **mysqlx-port**: the value of ``MYSQLX_PORT`` is used (if set), otherwise, ``33060`` is used by default.
99
100
* **host**: the value of ``MYSQL_HOST`` is used (if set), otherwise, ``127.0.0.1`` (localhost) is used by default.
100
101
101
102
The previous defaults conform to the standard or default configuration implemented by the MySQL server. Actually, there are many more flags available, you can explore them via ``python unittests.py --help``.
@@ -124,12 +125,19 @@ If you do not provide any flag regarding *control of the unit tests selection*,
124
125
- cursor
125
126
- errors
126
127
- mysql_datatypes
128
+
- mysqlx_connection
129
+
- mysqlx_crud
130
+
- mysqlx_errorcode
131
+
- mysqlx_pooling
127
132
- network
128
133
- optionfiles
129
134
- pooling
130
135
- protocol
131
136
- qa_bug16217743
132
137
- qa_caching_sha2_password
138
+
- qa_mysqlx_crud_view
139
+
- qa_mysqlx_session_reset
140
+
- qa_mysqlx_table_column_metadata
133
141
- utils
134
142
135
143
The list is not complete, but you can deduce and find more module names by inspecting the **tests** folder and its subfolders.
@@ -147,6 +155,7 @@ The script uses the environment variables described previously and introduces a
147
155
* ``NO_PROXY`` (value of the environment variable in the host by default)
148
156
* ``PYPI_REPOSITORY`` (https://pypi.org/pypi by default)
149
157
* ``MYSQL_CEXT`` (used to control the building of the **connector.mysql** C-EXT. If set to ``true`` or ``yes``, the extension is built, otherwise it is not)
158
+
* ``MYSQLX_CEXT`` (same usage as ``MYSQL_CEXT``, but for the **mysqlx** package)
150
159
* ``MYSQL_SOCKET`` (described below)
151
160
152
161
There is one additional environment variable called ``TEST_PATTERN`` which can be used to provide a string or a regular expression that is applied for filtering one or more matching unit tests to execute.
@@ -163,7 +172,15 @@ If you want to run **connector.mysql** tests related to the C-EXT functionality
In the examples above, a standard MySQL server configuration is assumed, that's the reason the values for ``MYSQL_HOST``, ``MYSQL_USER`` or ``MYSQL_PORT`` weren't specified.
175
+
You can also enable the **mysqlx** C-EXT by injecting a similar parameter::
In the examples above, a standard MySQL server configuration is assumed, that's the reason the values for ``MYSQL_HOST``, ``MYSQL_USER``, ``MYSQL_PORT`` or ``MYSQLX_PORT`` weren't specified.
167
184
168
185
For **Windows** users, you can set up a suitable environment to run bash scripts by installing `Git Bash <https://git-scm.com/>`_, and using the console it provides instead of the natives *PowerShell* or *CMD*.
169
186
@@ -175,20 +192,23 @@ On **macOS** and **Windows**, since containers run on a virtual machine, host lo
175
192
176
193
Due to some `know limitations <https://github.com/docker/for-mac/issues/483>`_ on the macOS Docker architecture, Unix socket tests can only run on Linux. In that case, if the ``MYSQL_SOCKET`` variable is explicitly specified, a shared volume between the host and the container will be created as a mount point from the socket file path in the host and an internal container directory specified as a volume, where the socket file path becomes available.
177
194
178
-
That being said, the following are some examples of possible use cases:
195
+
That being said, the following there are some examples of possible use cases:
179
196
180
-
* Running the test modules whose name follows the pattern ``c.*`` from a mac whose IP is ``232.188.98.520``, and the password for ``root`` is ``s3cr3t``. Classic protocol is listening on port ``3306``::
197
+
* Running the test modules whose name follows the pattern ``c.*`` from a mac whose IP is ``232.188.98.520``, and the password for ``root`` is ``s3cr3t``. Classic and XDevAPI protocols listening on ports ``3306`` and ``33060`` respectively::
* Running the whole test suite from Linux with MySQL user account ``docker``, and password ``s3cr3t``. Classic protocol is listening on port ``3308``::
201
+
* Running the whole test suite from Linux with MySQL user account ``docker``, and password ``s3cr3t``. Classic and XDevAPI protocols listening on ports ``3308`` and ``33060`` respectively::
* Running the *bugs* test module from Linux with MySQL user account ``root``, and password ``empty_string``. Classic and XDevAPI protocols listening on ports ``3306`` and ``33070`` respectively::
MySQL Connector/Python enables Python programs to access MySQL databases, using an API that is compliant with the `Python Database API Specification v2.0 (PEP 249) <https://www.python.org/dev/peps/pep-0249/>`_.
11
+
MySQL Connector/Python enables Python programs to access MySQL databases, using an API that is compliant with the `Python Database API Specification v2.0 (PEP 249) <https://www.python.org/dev/peps/pep-0249/>`_. It also contains an implementation of the `X DevAPI <https://dev.mysql.com/doc/x-devapi-userguide/en>`_, an Application Programming Interface for working with the `MySQL Document Store <https://dev.mysql.com/doc/refman/8.0/en/document-store.html>`_.
12
12
13
13
Installation
14
14
------------
@@ -17,10 +17,9 @@ The recommended way to install Connector/Python is via `pip <https://pip.pypa.io
17
17
18
18
Make sure you have a recent `pip <https://pip.pypa.io/>`_ version installed on your system. If your system already has ``pip`` installed, you might need to update it. Or you can use the `standalone pip installer <https://pip.pypa.io/en/latest/installing/#installing-with-get-pip-py>`_.
19
19
20
-
Classic connector:
21
-
22
-
$ pip install mysql-connector-python
20
+
.. code-block:: bash
23
21
22
+
shell> pip install mysql-connector-python
24
23
25
24
Please refer to the `installation tutorial <https://dev.mysql.com/doc/dev/connector-python/8.0/installation.html>`_ for installation alternatives.
26
25
@@ -53,8 +52,38 @@ Using the MySQL classic protocol:
# Specify which document to find with Collection.find()
73
+
result = collection.find("name like :param") \
74
+
.bind("param", "S%") \
75
+
.limit(1) \
76
+
.execute()
77
+
78
+
# Print document
79
+
docs = result.fetch_all()
80
+
print(r"Name: {0}".format(docs[0]["name"]))
81
+
82
+
# Close session
83
+
session.close()
84
+
56
85
57
-
Please refer to the `MySQL Connector/Python Developer Guide <https://dev.mysql.com/doc/connector-python/en/>`_ for a complete usage guide.
86
+
Please refer to the `MySQL Connector/Python Developer Guide <https://dev.mysql.com/doc/connector-python/en/>`_ and the `MySQL Connector/Python X DevAPI Reference <https://dev.mysql.com/doc/dev/connector-python/>`_ for a complete usage guide.
0 commit comments