Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add experimental flag to keep connections alive between invocations. #10797

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading