Documentation Home
MySQL Connector/Python Release Notes
Related Documentation Download these Release Notes
PDF (US Ltr) - 327.1Kb
PDF (A4) - 328.2Kb


MySQL Connector/Python Release Notes  /  Changes in MySQL Connector/Python 8.x  /  Changes in MySQL Connector/Python 8.0.21 (2020-07-13, General Availability)

Changes in MySQL Connector/Python 8.0.21 (2020-07-13, General Availability)

Functionality Added or Changed

  • On macOS, the official supported Protobuf version is versions before 3.12.0. (Bug #31390263)

  • Implemented context managers to define the runtime context to establish when executing a with statement. It was added to the Connection and Cursor objects in the classic protocol, and to Session in the X DevAPI. Thanks to WEN-FENG SHIH for the patch. (Bug #19586444, Bug #71663, Bug #28779784, Bug #89113, WL #13847)

  • Added compression support to X Protocol connections. Supported compression algorithms are zlib/deflate and lz4. Specifically, the supported algorithms (in order of preference) are lz4_message and deflate_stream. The compression threshold is set at 1000 bytes.

    A new compress X DevAPI connection option accepts either required, disabled, or preferred (default).

    • preferred: If Connector/Python and the server cannot reach consensus on algorithm or styles, then no compression is used; and this is logged.

    • required: Like preferred, except the connection is terminated with an error if the connector and server are unable to reach agreement.

    • disabled: Compression is not used.

    (WL #12501)

  • Document Store: Connector/Python now provides JSON schema validation for a collection to enforce a certain structure that documents must adhere to before they are permitted to be inserted or updated. Schema validation is performed by the server, which returns an error message if a document in a collection does not match the schema definition or if the server does not support validation.

    The schema.create_collection method added a new validation parameter as a dictionary or string representation of a JSON schema specification. The level of enforcement (off or strict, strict by default) and schema definition are specified as per this example:

    coll = schema.create_collection("longlang", validation={
        "level": "strict",
        "schema":   {
            "id": "http://json-schema.org/geo",
            "$schema": "http://json-schema.org/draft-06/schema#",
            "description": "A geographical coordinate",
            "type": "object",
            "properties": {
                "latitude": {
                    "type": "number"
                },
                "longitude": {
                    "type": "number"
                }
            },
            "required": ["latitude", "longitude"]
        }
    })

    In addition, a new schema.modify_collection method permits the schema validation of an existing collection to be reset. The validation collection option must include either a modified level value or schema value, or both. (WL #13059)

Bugs Fixed

  • The connect_timeout option applied to all blocking socket operations but now properly only applies to the timeout when establishing the connection. (Bug #30996790)

  • In X DevAPI implementation, an error was raised when using the fractional part in DATETIME types. The error: "ValueError: Datetime mapping scenario unhandled" (Bug #30950184)

  • Because MySQL stores TEXT types as BLOB and JSON as LONGBLOB, the TEXT and JSON types are now converted to str and the rest of the BLOB types as bytes. Previously, as an example, a column of type TEXT that only contained digits was read as type=integer by Connector/Python. (Bug #29808262, Bug #95437)

  • Connector/Python assumed that MySQL libraries were under lib/ when compiling the C extension, but now uses the mysql_config flags which adds the correct include and libraries paths. Thanks to DaniĆ«l van Eeden for the patch. (Bug #29181907, Bug #93846)

  • Attempting to change values using the Table object would yield an "Unknown column 'doc' in 'field list'" exception when using the X DevAPI. (Bug #28627768, Bug #27602636)