Skip to content

Commit

Permalink
Add experimental flag to keep connections alive between invocations.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterallenwebb committed Sep 30, 2024
1 parent 1fe9c1b commit f7d888f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions core/dbt/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def global_flags(func):
@p.fail_fast
@p.favor_state
@p.indirect_selection
@p.keep_connections_alive
@p.log_cache_events
@p.log_file_max_bytes
@p.log_format
Expand Down
8 changes: 8 additions & 0 deletions core/dbt/cli/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,3 +734,11 @@ def _version_callback(ctx, _param, value):
envvar="DBT_SHOW_RESOURCE_REPORT",
hidden=True,
)

keep_connections_alive = click.option(
"--keep-connections-alive/--no-keep-connections-alive",
envvar=None,
help="Experimental: Keep connections alive between dbt invocations. Useful when using dbt as an API.",
default=False,
is_flag=True,
)
4 changes: 2 additions & 2 deletions core/dbt/cli/requires.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ def wrapper(*args, **kwargs):
if flags.RECORD_TIMING_INFO:
ctx.with_resource(profiler(enable=True, outfile=flags.RECORD_TIMING_INFO))

# Adapter management
ctx.with_resource(adapter_management())
if not flags.KEEP_CONNECTIONS_ALIVE:
ctx.with_resource(adapter_management())

return func(*args, **kwargs)

Expand Down

0 comments on commit f7d888f

Please sign in to comment.