Documentation Home
MySQL Utilities 1.5 Manual
Related Documentation Download this Manual
PDF (US Ltr) - 1.5Mb
PDF (A4) - 1.5Mb
HTML Download (TGZ) - 289.5Kb
HTML Download (Zip) - 301.7Kb

MySQL Utilities 1.5 Manual  /  MySQL Fabric  /  Using Connector/Python with MySQL Fabric

8.8 Using Connector/Python with MySQL Fabric

MySQL Fabric provides data distribution and high-availability features for a set of MySQL database servers.

Developers using Connector/Python can take advantage of its features to work with a set of servers managed by MySQL Fabric. Connector/Python supports the following MySQL Fabric capabilities:

  • Automatic node selection based on application-provided shard information (tables and key)

  • Read/write splitting within a MySQL Fabric high-availability group

More specifically, Connector/Python Fabric support provides these features:

  • Requesting a connection to a MySQL server managed by Fabric is as transparent as possible to users already familiar with Connector/Python.

  • Connector/Python is able to get a MySQL server connection given a high-availability group and a mode specifying whether the connection is read-only or also permits updates (read-write).

  • Connector/Python supports sharding and is able to find the correct MySQL server for a given table or tables and key based on scope (local or global) and mode (read-only or read-write). RANGE and HASH mechanisms are supported transparently to the user.

  • Among secondary MySQL servers in the same group, read-only connections are load balanced. Load balancing is based on a weight set for each MySQL server, using a Weighted Round-Robin algorithm.

  • Faulty MySQL servers are reported to Fabric, and failover is supported when failure occurs for a server in a group.

  • To speed up operations, Connector/Python caches information obtained from Fabric, such as group and sharding information. Each time Connector/Python looks up data, it first checks its cache. When information in the cache is too old, it is invalidated. By default, the time-to-live (TTL) for cached information is 1 minute. However, Fabric itself can provide this TTL for its clients and this value is used instead if greater than zero.

    Cache information is also invalidated when failures occur, such as when a connection to a MySQL server fails (invalidation applies to the group to which the server belongs).

  • Fabric support applies to versions of Python supported by Connector/Python itself (see Connector/Python Versions). In particular, you can use Connector/Python with Python 3.1 and later to establish Fabric connections, even though Fabric does not support Python 3.

Connector/Python support for Fabric comprises the following module and classes:

  • Module mysql.connector.fabric: All classes, functions, and constants related to MySQL Fabric.

  • Class fabric.MySQLFabricConnection: Similar to MySQLConnection, it creates a connection to the MySQL server based on application-provided information.

  • Class fabric.Fabric: Manages the connection with a MySQL Fabric node; used by MySQLFabricConnection.

  • Other helper classes for caching information.

User Comments
Sign Up Login You must be logged in to post a comment.