From 8c06375144ac00b56754ca400a102c9b3f7b60e7 Mon Sep 17 00:00:00 2001 From: Josh lloyd Date: Wed, 17 Jul 2024 13:41:16 -0600 Subject: [PATCH] made the default schema configurable --- README.md | 1 + meltano.yml | 10 +++------- tap_mysql/client.py | 2 +- tap_mysql/tap.py | 7 +++++++ 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 183fbe5..21956d7 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ tap-mysql --about --format=markdown | port | False | 3306 | The port number of the MySQL instance. | | user | True | None | The username | | password | True | None | The password for the user | +| schema | False | mysql | The default schema for the connection string. | | custom_streams | False | None | An array of customized streams to use. | | stream_maps | False | None | Config object for stream maps capability. For more information check out [Stream Maps](https://sdk.meltano.com/en/latest/stream_maps.html). | | stream_map_config | False | None | User-defined config values to be used within map expressions. | diff --git a/meltano.yml b/meltano.yml index ccd5097..582aad1 100644 --- a/meltano.yml +++ b/meltano.yml @@ -27,13 +27,9 @@ plugins: custom_streams: - name: example_query_name db_schemas: - - db_schema1 - - db_schema2 - sql: SELECT * FROM {db_schema}.table1 LIMIT 5 - - name: example_query_name2 - db_schemas: - - db_schema1 - sql: SELECT * FROM db_schema1.table1 LIMIT 5 + - lloyd + - testencryptedrds + sql: SELECT '2024-07-16 00:00:00 +0:00' AS snapshot_date , ag.displayname AS asset_group_name , ag.id AS asset_group_id , SUM(fileSize) / 1024 / 1024 / 1024 AS storage_amount FROM {db_schema}.filesondisk AS f JOIN {db_schema}.assetversion AS v ON f.id = v.originalFile JOIN {db_schema}.directorasset AS d ON v.parentAsset = d.id JOIN {db_schema}.assetgroupassignments AS aga ON d.id = aga.assetId JOIN {db_schema}.assetgroups AS ag ON aga.groupId = ag.id WHERE v.dateAdded < '2024-07-16 00:00:00 +0:00' AND (d.dateRemoved IS NULL OR d.dateRemoved > '2024-07-16 00:00:00 +0:00') GROUP BY 1,2,3 select: - '*-example_query_name.*' loaders: diff --git a/tap_mysql/client.py b/tap_mysql/client.py index c99fad7..4e45c72 100644 --- a/tap_mysql/client.py +++ b/tap_mysql/client.py @@ -55,7 +55,7 @@ def get_sqlalchemy_url(cls, config: dict) -> str: f"{config['password']}@" f"{config['host']}:" f"{config['port']}/" - f"mysql" + f"{config['schema']}" ) @staticmethod diff --git a/tap_mysql/tap.py b/tap_mysql/tap.py index a0e62eb..6002b4a 100644 --- a/tap_mysql/tap.py +++ b/tap_mysql/tap.py @@ -75,6 +75,13 @@ class TapMySQL(SQLTap): secret=True, description="The password for the user", ), + th.Property( + "schema", + th.StringType, + required=False, + default="mysql", + description="The default schema for the connection string.", + ), th.Property( "custom_streams", th.ArrayType(custom_stream_config),