From 8c2d1242b6082c37d2ae0da238bf63480e833284 Mon Sep 17 00:00:00 2001 From: Derek Visch Date: Wed, 21 Feb 2024 00:15:19 -0500 Subject: [PATCH] Fix config validation, and messup with connect function call --- tap_mysql/client.py | 2 +- tap_mysql/tap.py | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/tap_mysql/client.py b/tap_mysql/client.py index 3689f48..9d4fb23 100644 --- a/tap_mysql/client.py +++ b/tap_mysql/client.py @@ -438,7 +438,7 @@ def get_records(self, context: dict | None) -> Iterable[dict[str, Any]]: if start_val: query = query.filter(replication_key_col >= start_val) - with self.connector.connect() as conn: + with self.connector._connect() as conn: # noqa: SLF001 if self.connector.is_vitess: conn.exec_driver_sql( "set workload=olap" diff --git a/tap_mysql/tap.py b/tap_mysql/tap.py index 1fb8e87..8ff3fc9 100644 --- a/tap_mysql/tap.py +++ b/tap_mysql/tap.py @@ -35,12 +35,16 @@ def __init__( See https://github.com/MeltanoLabs/tap-postgres/issues/141 """ super().__init__(*args, **kwargs) - if (self.config.get("sqlalchemy_url") is not None) or ( - self.config.get("host") is not None - and self.config.get("port") is not None - and self.config.get("user") is not None - and self.config.get("password") is not None - ): + sql_alchemy_url_exists = self.config.get("sqlalchemy_url") is not None + individual_url_params_exist = all( + [ + self.config.get("host") is not None, + self.config.get("port") is not None, + self.config.get("user") is not None, + self.config.get("password") is not None, + ] + ) + if not (sql_alchemy_url_exists or individual_url_params_exist): msg = ( "Need either the sqlalchemy_url to be set or host, port, " "user, and password to be set"