MySQL Utilities

2.2.2 Specifying Connections in Python Library

If you build your own utilities using the MySQL Utilities library, there are various methods for connecting to MySQL servers. Methods that deal with connecting to servers can accept the following mechanisms for supplying the data.

The dictionary lists the values by name as described above. For example, you would create code like the following.

# Set connection values
dest_values = {
    "user" : "root",
    "passwd" : "secret",
    "host" : "localhost",
    "port" : 3308,
    "unix_socket" : None,

The connection specification is a string the form user[:passwd]@host[:port][:socket] where the passwd, port, and socket are optional. This string is parsed using the options.parse_connection function.

You can also specify an existing instance of the Server class. In this case, the new class copies the connection information.