feat: support basic user/password auth with MySQLEngine#17
Conversation
| # override MySQLEngine._connector to allow a new Connector to be initiated | ||
| MySQLEngine._connector = None |
There was a problem hiding this comment.
this is required for testing purposes because MySQLEngine._connector is a class attribute to be re-used across engines. However, the Cloud SQL Python Connector does not allow the same connector to be called with enable_iam_auth set to False and then also be called with it set to True which happens when you create an engine with basic auth and then again with defaulting to iam authn.
I think customers would use one or the other, i don't see a use-case for customers wanting to use both.
| ) | ||
| iam_database_user = _get_iam_principal_email(credentials) | ||
| # if user and password are given, use basic auth | ||
| if user and password: |
There was a problem hiding this comment.
should we throw an error if they specify user and not password (or vica versa)?
There was a problem hiding this comment.
added an error, catching it up a level using XOR logic in the .from_instance() class method for easier developer experience with stacktrace coming from a public method instead of the internal _create_connector_engine
Adding basic user/password auth support to
MySQLEngine.from_instance()through optionaluserandpasswordargs.