Package: dbtenv
dbtenvdbtenv is a version manager for dbt, automatically installing and switching to the needed adapter and version ofdbt.QuickstartInstallationInstallpipx(What is pipx?).Runpipx install dbtenv-dbt-aliasUsageIfdbtenv-dbt-aliasis installed per the above, dbt commands can be used as normal and will be routed through dbtenv. dbtenv will automatically determine, install and use the required dbt adapter and version.Illustrative example➜  dev/dbt_project ✗ dbt compile
dbtenv info:  Using dbt-bigquery==1.0.0 (set by dbt_project.yml).
10:48:43  Running with dbt=1.0.4

10:48:45  Found 73 models, 142 tests, 2 snapshots, 0 analyses, 383 macros, 0 operations, 0 seed files, 44 sources, 0 exposures, 0 metrics
10:48:45
10:49:14  Concurrency: 1 threads (target='dev')
10:49:14
10:49:20  Done.Installation OptionsThere are two packages available for installation:dbtenvdbtenv-dbt-aliasdbtenv-dbt-aliasis identical todbtenv, with the exception of adding adbtentry point. Thedbtcommand then acts as a direct shortcut todbtenv execute --, and means that dbtenv can used as a drop-in replacement to installing dbt normally.Available Commandsdbtenv --help- Print documentation and available commands. Can also be run for information on a individual command, e.g.dbtenv versions --help.dbtenv versions- List the installable versions of dbt, marking those which are currently installed. Add the--installedflag to show only those which are installed.dbtenv install <dbt_pip_specifier>- Install a specific version of dbt, e.g.dbtenv install dbt-snowflake==1.0.0.dbtenv uninstall <dbt_pip_specifier>- Uninstall a specific version of dbt, e.g.dbtenv uninstall dbt-snowflake==1.0.0.dbtenv version- Print the dbt version dbtenv determines automatically for the current environment.dbtenv which- Print the full path to the executable of the dbt version dbtenv determines automatically for the current environment.dbtenv execute- Execute a dbt command.Ifdbtenv-dbt-aliasis installed:All the above plus:dbt <args>- The dbt CLI.dbt Version Managementdbtenv will automatically install the required version of dbt for the current project by default. To disable this behaviour, set the environment variableDBTENV_AUTO_INSTALLtofalse.By default, dbtenv creates virtual environments for each dbt package version within~/.dbt/versions. You can customize this location by setting theDBTENV_VENVS_DIRECTORYenvironment variable.By default, dbtenv uses whichever Python version it was installed with to install dbt, but that can be changed by setting aDBTENV_PYTHONenvironment variable to the path of a different Python executable, or specifying--python <path>when runningdbtenv install.Switching between dbt versionsAdapter typeIf dbtenv is invoked within a dbt project, dbtenv will look for the project's default target adapter type inprofiles.yml. If dbt's--targetargument is set, dbtenv will use that target's adapter type instead. To use thedbtenv executecommand outside of a dbt project (such asdbt init), a pip specifier should be passed to dbtenv execute's--dbtargument so that dbtenv knows which adapter to use.dbt versiondbtenv determines the dbt version to use from the following sources, using the first one it finds:Thedbtenv executecommand's optional--dbt <version>argument.TheDBT_VERSIONenvironment variable.If not running within a dbt project:The first.dbt_versionfile found searching the working directory path (local version).The~/.dbt/versionfile (global version).The current dbt project'sdbt_project.ymlversion requirements.If a local or global dbt version has been set, dbtenv will use that version if in the range set byrequire-dbt-version.The locally or globally set version.The max installed dbt version (preferring stable versions).The max installable dbt version (preferring stable versions).You can:Rundbtenv version --global <version>to set the dbt version globally in the~/.dbt/versionfile. The<version>can be either a dbt version (e.g. 1.0.0) or full pip specifier (e.g. dbt-snowflake==1.0.0). dbtenv will attempt to automatically detect the required adapter or version from the environment if not specified.Rundbtenv version --local <version>to set the dbt version for the current directory in a.dbt_versionfile. The<version>can be either a dbt version (e.g. 1.0.0) or full pip specifier (e.g. dbt-snowflake==1.0.0). dbtenv will attempt to automatically detect the required adapter or version from the environment if not specified.Running dbt through dbtenvIf dbtenv-dbt-alias installedThedbtcommand then acts as a direct shortcut todbtenv execute --, and means that dbtenv can used as a drop-in replacement to installing dbt normally. dbtenv will automatically identify which package and version of dbt to use. If you need to manually specify a dbt package version to run with, use thedbtenv executecommand.dbtenv executeRundbtenv execute -- <dbt arguments>to execute the dbt version determined automatically from the current environment, or rundbtenv execute --dbt <version> -- <dbt arguments>to execute a specific dbt version.For example:dbtenv execute -- runwill executedbt runusing the version determined automatically from the current environment.dbtenv execute --dbt 1.0.0 -- runwill executedbt runusing dbt 1.0.0, automatically detecting the required adapter from the default target inprofiles.yml.dbtenv execute --dbt 1.0.0 -- run --target prodwill executedbt runusing dbt 1.0.0, using the required adapter for the 'prod' target inprofiles.yml.dbtenv execute --dbt dbt-bigquery==1.0.0 -- runwill executedbt runusing dbt-bigquery==1.0.0.DevelopmentDevelopment setupClone this repository onto your computer.Install Poetrypipx install poetry(What is pipx?)Navigate to thedbtenvdirectory, and install the project into a virtual environmentpoetry installActivate the virtual environmentpoetry shellAnydbtenvcommands will run using the local version of the project.