Merge pull request #781 from gottwald/devel-mysql-socketOption

login_unix_socket option for mysql modules
pull/790/head
Michael DeHaan 12 years ago
commit 092f83e6f8

@ -71,6 +71,7 @@ def main():
login_user=dict(default=None), login_user=dict(default=None),
login_password=dict(default=None), login_password=dict(default=None),
login_host=dict(default="localhost"), login_host=dict(default="localhost"),
login_unix_socket=dict(default=None),
db=dict(required=True, aliases=['name']), db=dict(required=True, aliases=['name']),
encoding=dict(default=""), encoding=dict(default=""),
collation=dict(default=""), collation=dict(default=""),
@ -103,6 +104,9 @@ def main():
module.fail_json(msg="when supplying login arguments, both login_user and login_password must be provided") module.fail_json(msg="when supplying login arguments, both login_user and login_password must be provided")
try: try:
if module.params["login_unix_socket"] != None:
db_connection = MySQLdb.connect(host=module.params["login_host"], unix_socket=module.params["login_unix_socket"], user=login_user, passwd=login_password, db="mysql")
else:
db_connection = MySQLdb.connect(host=module.params["login_host"], user=login_user, passwd=login_password, db="mysql") db_connection = MySQLdb.connect(host=module.params["login_host"], user=login_user, passwd=login_password, db="mysql")
cursor = db_connection.cursor() cursor = db_connection.cursor()
except Exception as e: except Exception as e:

@ -164,6 +164,7 @@ def main():
login_user=dict(default=None), login_user=dict(default=None),
login_password=dict(default=None), login_password=dict(default=None),
login_host=dict(default="localhost"), login_host=dict(default="localhost"),
login_unix_socket=dict(default=None),
user=dict(required=True, aliases=['name']), user=dict(required=True, aliases=['name']),
password=dict(default=None), password=dict(default=None),
host=dict(default="localhost"), host=dict(default="localhost"),
@ -203,6 +204,9 @@ def main():
module.fail_json(msg="when supplying login arguments, both login_user and login_password must be provided") module.fail_json(msg="when supplying login arguments, both login_user and login_password must be provided")
try: try:
if module.params["login_unix_socket"] != None:
db_connection = MySQLdb.connect(host=module.params["login_host"], unix_socket=module.params["login_unix_socket"], user=login_user, passwd=login_password, db="mysql")
else:
db_connection = MySQLdb.connect(host=module.params["login_host"], user=login_user, passwd=login_password, db="mysql") db_connection = MySQLdb.connect(host=module.params["login_host"], user=login_user, passwd=login_password, db="mysql")
cursor = db_connection.cursor() cursor = db_connection.cursor()
except Exception as e: except Exception as e:

Loading…
Cancel
Save