psql command
This information applies to Databricks CLI versions 0.285 and above. The Databricks CLI is in Public Preview.
Databricks CLI use is subject to the Databricks License and Databricks Privacy Notice, including any Usage Data provisions.
The psql command within the Databricks CLI allows you to connect to a Lakebase Postgres database using a PostgreSQL client. It supports both Lakebase Provisioned instances and Lakebase Autoscaling projects.
databricks psql
Connect to a Lakebase Postgres database. This command requires a psql client to be installed on your machine.
The command includes automatic retry logic for connection failures. You can configure the retry behavior using the --max-retries flag.
databricks psql [TARGET] [flags] [-- PSQL_ARGS...]
Arguments
TARGET
The target to connect to. For Lakebase Provisioned, specify the instance name. For Lakebase Autoscaling, specify the full path in the form projects/<project>/branches/<branch>/endpoints/<endpoint>. If omitted, the command lists available databases for interactive selection.
PSQL_ARGS (optional)
Additional arguments to pass to the psql client. Specify these after a double-dash (--) separator.
Options
--autoscaling
Only show Lakebase Autoscaling projects when listing available databases.
--branch string
Branch ID for Lakebase Autoscaling. Defaults to auto-select when only one branch exists.
--endpoint string
Endpoint ID for Lakebase Autoscaling. Defaults to auto-select when only one endpoint exists.
--max-retries int
Maximum number of connection retry attempts. Set to 0 to disable retries. Default: 3.
--project string
Project ID for Lakebase Autoscaling.
--provisioned
Only show Lakebase Provisioned instances when listing available databases.
Examples
The following example connects to a Lakebase Provisioned instance:
databricks psql my-instance
The following example connects to a Lakebase Autoscaling project using flags:
databricks psql --project my-project --branch main --endpoint primary
The following example connects to a Lakebase Autoscaling project using the full path:
databricks psql projects/my-project/branches/main/endpoints/primary
The following example lists only Lakebase Autoscaling projects for interactive selection:
databricks psql --autoscaling
The following example passes additional arguments to the psql client:
databricks psql my-instance -- -c "SELECT 1"
The following example connects with retries disabled:
databricks psql my-instance --max-retries 0
Global flags
--debug
Whether to enable debug logging.
-h or --help
Display help for the Databricks CLI or the related command group or the related command.
--log-file string
A string representing the file to write output logs to. If this flag is not specified then the default is to write output logs to stderr.
--log-format format
The log format type, text or json. The default value is text.
--log-level string
A string representing the log format level. If not specified then the log format level is disabled.
-o, --output type
The command output type, text or json. The default value is text.
-p, --profile string
The name of the profile in the ~/.databrickscfg file to use to run the command. If this flag is not specified then if it exists, the profile named DEFAULT is used.
--progress-format format
The format to display progress logs: default, append, inplace, or json
-t, --target string
If applicable, the bundle target to use