-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow connecting to the DB from a specific network interface #529
Conversation
(hostname or IP address)
just a note we are imitating MySQL's own API here, which should also be supported in mysqlclient: MYSQL_OPT_BIND at http://dev.mysql.com/doc/refman/5.7/en/mysql-options.html |
@@ -534,7 +534,8 @@ def __init__(self, host=None, user=None, password="", | |||
compress=None, named_pipe=None, no_delay=None, | |||
autocommit=False, db=None, passwd=None, local_infile=False, | |||
max_allowed_packet=16*1024*1024, defer_connect=False, | |||
auth_plugin_map={}, read_timeout=None, write_timeout=None): | |||
auth_plugin_map={}, read_timeout=None, write_timeout=None, | |||
bind=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer bind_address rather than bind. (Same to option name, translated '-' with '_')
@@ -640,6 +645,9 @@ def _config(key, arg): | |||
self.password = password or "" | |||
self.db = database | |||
self.unix_socket = unix_socket | |||
if bind is not None and _py_version == (2, 6): | |||
raise NotImplementedError("bind before connect is not supported in Python 2.6") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Python 2.6 is not supported anymore. So this check is not required.
thanks |
When connecting via TCP/IP, provide a means to the client to bind the
socket to be created to a specific source address. This is useful
when the client host has multiple network interfaces and a specific
one must be used for database traffic.
Add a new optional "bind" argument to class Connection, to specify the
interface from which to connect to the DB. Argument can be a hostname
or an IP address.