node-mysql2
node-mysql2 copied to clipboard
Feature Request: Allow setting connectionAttributes in the connectionConfig
Trying to set the program_name value on the connection so I can define which program is accessing the database. Using JDBC it would be handled in the connection string:
jdbc:mysql://localhost/database?connectionAttributes=program_name:Login Server,other_name:other
Setting the attributes currently gives an invalid configuration warning about connectionAttributes not being supported. It would be helpful to be able to get these options in there.
https://dev.mysql.com/doc/refman/5.7/en/performance-schema-connection-attribute-tables.html
agree, that would be a useful feature. If I direct you to related parts of the code would you be able to contribute this?
I'd be more than happy to give it a shot
so we already have "connectAttributes" as a valid field in ConnectionConfig, when set it'll be passed as keys:values object during client handshake response. We probably need to add support for it in the parseUrl here https://github.com/sidorares/node-mysql2/blob/dadef383098b0823a90e07fbec18639bd612adfb/lib/connection_config.js#L251
Not sure if worth renaming to connectionAttributes but we could add it as an alias ( so that both connectAttributes and connectionAttributes mean the same )
Awesome. I'll dig into it. Thanks for the pointer!