Documentation Home
X DevAPI User Guide for MySQL Shell in Python Mode
Download this Manual
PDF (US Ltr) - 1.2Mb
PDF (A4) - 1.2Mb


2.2.3 Connection Attributes

Connection attributes are key-value pairs that application programs can pass to the server during connection time to be stored in the PERFORMANCE_SCHEMA tables session_account_connect_attrs and session_connect_attrs. There are two different kinds of connection attributes:

  • Client-defined attributes are reserved key-value mappings implicitly encoded by a client. The set of client-defined attributes differ from client to client—see the X DevAPI references of you client for details. The client-defined attributes are sent to the server by default.

  • User-defined attributes are key-value mappings provided by the user or application.

X DevAPI supports MySQL connection attributes through the connection parameter connection-attributes (xdevapi.connection-attributes for Connector/J), set through the getSession() and getClient() methods. Here are the different ways to use the parameter:

  • These settings for the parameter are equivalent to the default behavior (that is, sending client-defined attributes) when the parameter is not used:

    • connection-attributes

    • connection-attributes=

    • connection-attributes=true

    • connection-attributes=[]

  • connection-attributes=false prevents any connection attributes to be sent, including the client-defined ones.

  • connection-attributes=[key1=value1,key2=value2, ...] sends user-defined connection attributes as key-value pairs alongside the client-defined connection attributes. When a value is missing from a key-value pair, a null value is set for the attribute

The following is a generic example of a connection string that configures the connection attributes:

mysqlx://user:password@localhost:33060?connection-attributes=[key1=value1,key2=value2,key3=]