Search code examples
command-line-interfacedbt

How to list (and count) all the models?


I'd like to list and count all the DBT models (every single .sql table) within my DBT project.

I see the dbt ls https://docs.getdbt.com/reference/commands/list but I'm new and can't make it work in order to list all the models.

Any suggestions?


Solution

  • dbt ls on its own will list all nodes which include tests, snapshots, seeds, etc. To list just the models you can run dbt ls --resource-type model. However, you don't want to pipe that directly into wc because dbt prints out logging info by default. To get around that you can add -q to the dbt command.

    dbt -q ls --resource-type model | wc -l