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

MySQL Utilities 1.5  /  ...  /  Specifying Connections in Python Library

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.

  • As a Python dictionary containing the connection parameters.

  • As a connection specification string containing the connection parameters.

  • As a Server instance.

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.

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