Skip to content

Commit

Permalink
Fix config validation, and messup with connect function call
Browse files Browse the repository at this point in the history
  • Loading branch information
visch committed Feb 21, 2024
1 parent 84fc4b3 commit 8c2d124
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion tap_mysql/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
16 changes: 10 additions & 6 deletions tap_mysql/tap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 8c2d124

Please sign in to comment.