bassel
07/18/2023, 4:36 AM- name: dev
config:
plugins:
extractors:
- name: tap-mysql
select:
- db-tableA.*
- db-tableB.*
- db-tableC.*
metadata:
db-tableA:
replication-method: INCREMENTAL
replication-key: updated_at
db-tableB:
replication-method: INCREMENTAL
replication-key: updated_at
db-tableC:
replication-method: INCREMENTAL
replication-key: updated_at
It works perfectly .. I added env vars to use in the yml file as following (I want to build the select tables config dynamically using the env var value):
- name: dev
config:
plugins:
extractors:
- name: tap-mysql
select:
- "${DB_NAME}-tableA.*"
- "${DB_NAME}-tableB.*"
- "${DB_NAME}-tableC.*"
metadata:
"${DB_NAME}-tableA":
replication-method: INCREMENTAL
replication-key: updated_at
"${DB_NAME}-tableB":
replication-method: INCREMENTAL
replication-key: updated_at
"${DB_NAME}-tableC":
replication-method: INCREMENTAL
replication-key: updated_at
But, its not working (not getting anything extracted - no errors in the logs) .. any ideas or thoughts?Andy Carter
07/18/2023, 7:50 AMbassel
07/18/2023, 12:14 PMuser
07/18/2023, 2:17 PMdouwe_maan
07/18/2023, 2:18 PMselect
from meltano.yml
• Update the metadata
keys to have *
instead of ${DB_NAME}
• When you run meltano elt tap-mysql target-<foo>
, pass --select "${DB_NAME}-tableA" --select "${DB_NAME}-tableB" --select "${DB_NAME}-tableC"
douwe_maan
07/18/2023, 2:18 PMdouwe_maan
07/18/2023, 2:18 PM--select
under https://docs.meltano.com/reference/command-line-interface#parameters-1bassel
07/18/2023, 2:19 PMbassel
07/18/2023, 2:19 PMmetadata:
${DB_NAME}-tableA:
replication-method: INCREMENTAL
replication-key: updated_at
douwe_maan
07/18/2023, 2:21 PM*
instead of ${DB_NAME}
to apply the rules to all streams. Then when you use --select
, only a subset of those streams will actually be pulled so the metadata options for the other streams are ignoredbassel
07/18/2023, 2:23 PMmetadata:
*-tableA:
replication-method: INCREMENTAL
replication-key: updated_at
user
07/18/2023, 2:24 PM*-tableB
with different properties as well, assuming that the DB_NAME will be different but they’ll all have the same tables with the same settingsbassel
07/18/2023, 2:51 PM*-dbname.*
?
Also, can I force it to select the default Db assigned to the user used in the connection string?bassel
07/18/2023, 2:59 PMselect
part is passed to tap-mysql's
code? maybe we can make a workarounduser
07/18/2023, 3:52 PMWhat if I did not specify the db name in the select statement or putThat will work, if you then limit the DBs in the connection string.?*-dbname.*
Can you help me identifying where theWhat part are you looking for exactly? Meltano interprets thepart is passed toselect
code? maybe we can make a workaroundtap-mysql's
select
property (and --select
flag) and metadata
property itself to generate a catalog that is then passed to the tap: https://docs.meltano.com/guide/integration#extractor-catalog-generation. The tap then interprets the selected
, replication-key
, and replication-method
catalog metadata. It’ll be cleanest (not requiring changes to tap-mysql) if we can get this to work using the `select`/`metadata` property and/or a way to limit the DB in the connection string passed to tap-mysql
.user
07/18/2023, 3:52 PMdatabase
config: https://hub.meltano.com/extractors/tap-mysql/#database-settinguser
07/18/2023, 3:53 PMselect
and metadata
rules in meltano.yml
can include *
where the DB name goesuser
07/18/2023, 3:53 PMbassel
07/18/2023, 4:32 PMescaped_db
replaced with the database_name
value in the connection string ..
select_sql = f'SELECT {",".join(escaped_columns)} FROM {escaped_db}.{escaped_table}'
https://github.com/transferwise/pipelinewise-tap-mysql/blob/master/tap_mysql/sync_strategies/common.py#L85
@douwe_maanuser
07/18/2023, 4:34 PMbassel
07/18/2023, 4:41 PM- name: tap-mysql
config:
host: $DB_HOST
port: $DB_PORT
user: $DB_USER
database: $DB_NAME
password: $DB_PASSWORD
select:
- "placholder-tableA.*"
metadata:
"placeholder-tableA":
replication-method: INCREMENTAL
replication-key: updated_at
I would take the value from database: $DB_NAME
and replace the placeholder
in the select
and metadata
fields ..
@douwe_maanbassel
07/18/2023, 4:50 PMfilter_dbs: $DB_NAME
select:
- "*-tableA.*"
metadata:
"*-tableA":
replication-method: INCREMENTAL
replication-key: updated_at
bassel
07/18/2023, 5:44 PMfilter_dbs: $DB_NAME
Worked! @douwe_maan Thanks