ansible/ansible — pull request #4342 by pileofrogs (2013-10-02 20:41:43+00:00)
Title: mysql_replication switch to DictCursor for compatibility with more mysql server versions

Hi, this is my first pull request. It's a small change to the mysql_replication module to make it work on more versions of mysql server.

mysql_replication's getslave and getmaster actions failed on my version of mysql because the fields returned by my version of mysql did not match those coded into mysql_replication.

The standard cursor object in python MySQLdb returns rows as arrays, while DictCursor returns them as dicts with the field name as the key in the dict. DictCursor is part of MySQLdb, so nothing funny there.

By using a DictCursor instead of the standard cursor, we get a mysql_replication that can be used across versions and is safe from any future changes because the field names are no longer hard coded but instead used from the output of the database. Also, the code is shorter, which is kind of nice.

The hard-coded field names from the original mysql_replication appear to be the same as the field names output my mysql, so this change does not break current setups that work with the current mysql_replication.

I'm pretty inexperienced at python, so it's entirely possible that I've just done something stupid and there was a very good reason for doing it with the standard cursor object instead of the DictCursor object.

Thanks for creating and maintaining ansible! It makes my brain hurt a lot less.

-Dylan