Greetings! A question for the community: since tar...
# singer-targets
s
Greetings! A question for the community: since target-postgres load_method is not implemented yet, anyone has any idea on how to truncate/empty the target table before inserting new data??
1
Nevermind, I figured it out
e
Hey @Samuel Nogueira Farrus, I'm curious what your solution looks like!
s
Oi mate, sorry, should have posted it. I created a
dbt-postgres
transform with the following content:
Copy code
{{
  config(
    pre_hook='truncate <schema>.<table>',
    post_hook='drop view <schema>.<transform_sql_file_name>'
  )
}}

select now()
and then set a
commands
in the
meltano.yml
:
Copy code
commands:
  truncate:
    args: run --select models/<truncate_file>.sql
  transform:
    args: run --exclude models/<truncate_file>.sql
So I run the ELT with:
Copy code
meltano run dbt-postgres:truncate <extractor> target-postgres dbt-postgres:transform
There you go, the target table is emptied before the insertion of new data
👌 1
e
Oh that's nice and clever!