-
Notifications
You must be signed in to change notification settings - Fork 16.4k
Description
Description
There is currently no way to pass an init_command connection argument for a mysql connection when using either the mysqlclient or mysql-connector-python libraries with the MySql provider's MySqlHook.
Documentation for connection arguments for mysqlclient library, listing init_command:
https://mysqlclient.readthedocs.io/user_guide.html?highlight=init_command#functions-and-attributes
Documentation for connection arguments for mysql-connector-python library, listing init_command:
https://dev.mysql.com/doc/connector-python/en/connector-python-connectargs.html
There can be many uses for init_command, but also what comes to mind is why do we explicitly provide support to certain connection arguments and not others?
Use case/motivation
For my own use right now I am currently am subclassing the hook and then altering the connection arguments to pass in init_command to set the time_zone session variable to UTC at connection time, like so:
conn_config['init_command'] = r"""SET time_zone = '+00:00';"""Note: This is just an example, there can be many other uses for init_command besides the example above. Also, I am aware there is a time_zone argument for connections via the mysql-connector-python library, however that argument is not supported by connections made with mysqlclient library. Both libraries do support the init_command argument.
Related issues
No response
Are you willing to submit a PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct