Skip to main content

postgres command group

note

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 postgres command group within the Databricks CLI contains commands to manage Lakebase Postgres resources including projects, branches, and endpoints. The Postgres API provides access to a Postgres database via REST API or direct SQL.

databricks postgres create-branch

Create a Branch.

note

This is a long-running operation. By default, the command waits for the operation to complete. Use --no-wait to return immediately with the raw operation details. The operation's name field can then be used to poll for completion using the get-operation command.

databricks postgres create-branch PARENT BRANCH_ID [flags]

Arguments

PARENT

    The Project where this Branch is created. Format: projects/{project_id}

BRANCH_ID

    The ID to use for the Branch, which becomes the final component of the branch's resource name. Must be 1-63 characters long, start with a lowercase letter, and contain only lowercase letters, numbers, and hyphens (RFC 1123).

Options

--json JSON

    The inline JSON string or the @path to the JSON file with the request body.

--name string

    The resource name of the branch.

--no-wait

    Don't wait to reach DONE state.

--timeout duration

    Maximum amount of time to reach DONE state.

Global flags

Examples

The following example creates a branch in a project:

Bash
databricks postgres create-branch projects/my-project-id my-branch \
--json '{
"spec": {
"no_expiry": true
}
}'

The following example creates a branch from an existing branch:

Bash
databricks postgres create-branch projects/my-project-id dev-branch \
--json '{
"spec": {
"source_branch": "projects/my-project-id/branches/main",
"no_expiry": true
}
}'

databricks postgres create-endpoint

Create an Endpoint.

note

This is a long-running operation. By default, the command waits for the operation to complete. Use --no-wait to return immediately with the raw operation details. The operation's name field can then be used to poll for completion using the get-operation command.

databricks postgres create-endpoint PARENT ENDPOINT_ID [flags]

Arguments

PARENT

    The Branch where this Endpoint is created. Format: projects/{project_id}/branches/{branch_id}

ENDPOINT_ID

    The ID to use for the Endpoint, which becomes the final component of the endpoint's resource name. Must be 1-63 characters long, start with a lowercase letter, and contain only lowercase letters, numbers, and hyphens (RFC 1123).

Options

--json JSON

    The inline JSON string or the @path to the JSON file with the request body.

--name string

    The resource name of the endpoint.

--no-wait

    Don't wait to reach DONE state.

--timeout duration

    Maximum amount of time to reach DONE state.

Global flags

Examples

The following example creates a read-write endpoint in a branch:

Bash
databricks postgres create-endpoint projects/my-project-id/branches/my-branch-id my-endpoint \
--json '{
"spec": {
"endpoint_type": "ENDPOINT_TYPE_READ_WRITE",
"autoscaling_limit_min_cu": 0.5,
"autoscaling_limit_max_cu": 4.0
}
}'

The following example creates a read-only endpoint (read replica):

Bash
databricks postgres create-endpoint projects/my-project-id/branches/my-branch-id read-replica-1 \
--json '{
"spec": {
"endpoint_type": "ENDPOINT_TYPE_READ_ONLY",
"autoscaling_limit_min_cu": 0.5,
"autoscaling_limit_max_cu": 4.0
}
}'

databricks postgres create-project

Create a Project.

note

This is a long-running operation. By default, the command waits for the operation to complete. Use --no-wait to return immediately with the raw operation details. The operation's name field can then be used to poll for completion using the get-operation command.

databricks postgres create-project PROJECT_ID [flags]

Arguments

PROJECT_ID

    The ID to use for the Project, which becomes the final component of the project's resource name. Must be 1-63 characters long, start with a lowercase letter, and contain only lowercase letters, numbers, and hyphens (RFC 1123).

Options

--json JSON

    The inline JSON string or the @path to the JSON file with the request body.

--name string

    The resource name of the project.

--no-wait

    Don't wait to reach DONE state.

--timeout duration

    Maximum amount of time to reach DONE state.

Global flags

Examples

The following example creates a project:

Bash
databricks postgres create-project my-project \
--json '{
"spec": {
"display_name": "My Project"
}
}'

The following example creates a project with a specific PostgreSQL version:

Bash
databricks postgres create-project my-project \
--json '{
"spec": {
"display_name": "My Project",
"pg_version": "17"
}
}'

databricks postgres delete-branch

Delete a Branch.

note

This is a long-running operation. By default, the command waits for the operation to complete. Use --no-wait to return immediately with the raw operation details. The operation's name field can then be used to poll for completion using the get-operation command.

databricks postgres delete-branch NAME [flags]

Arguments

NAME

    The name of the Branch to delete. Format: projects/{project_id}/branches/{branch_id}

Options

--no-wait

    Don't wait to reach DONE state.

--timeout duration

    Maximum amount of time to reach DONE state.

Global flags

Examples

The following example deletes a branch:

Bash
databricks postgres delete-branch projects/my-project-id/branches/my-branch-id

databricks postgres delete-endpoint

Delete an Endpoint.

note

This is a long-running operation. By default, the command waits for the operation to complete. Use --no-wait to return immediately with the raw operation details. The operation's name field can then be used to poll for completion using the get-operation command.

databricks postgres delete-endpoint NAME [flags]

Arguments

NAME

    The name of the Endpoint to delete. Format: projects/{project_id}/branches/{branch_id}/endpoints/{endpoint_id}

Options

--no-wait

    Don't wait to reach DONE state.

--timeout duration

    Maximum amount of time to reach DONE state.

Global flags

Examples

The following example deletes an endpoint:

Bash
databricks postgres delete-endpoint projects/my-project-id/branches/my-branch-id/endpoints/my-endpoint-id

databricks postgres delete-project

Delete a Project.

note

This is a long-running operation. By default, the command waits for the operation to complete. Use --no-wait to return immediately with the raw operation details. The operation's name field can then be used to poll for completion using the get-operation command.

databricks postgres delete-project NAME [flags]

Arguments

NAME

    The name of the Project to delete. Format: projects/{project_id}

Options

--no-wait

    Don't wait to reach DONE state.

--timeout duration

    Maximum amount of time to reach DONE state.

Global flags

Examples

The following example deletes a project:

Bash
databricks postgres delete-project projects/my-project-id

databricks postgres generate-database-credential

Generate OAuth credentials for a Postgres database.

databricks postgres generate-database-credential ENDPOINT [flags]

Arguments

ENDPOINT

    The endpoint for which this credential is generated. Format: projects/{project_id}/branches/{branch_id}/endpoints/{endpoint_id}

Options

--json JSON

    The inline JSON string or the @path to the JSON file with the request body.

Global flags

Examples

The following example generates OAuth credentials for an endpoint:

Bash
databricks postgres generate-database-credential projects/my-project-id/branches/my-branch-id/endpoints/my-endpoint-id

databricks postgres get-branch

Get a Branch.

databricks postgres get-branch NAME [flags]

Arguments

NAME

    The name of the Branch to retrieve. Format: projects/{project_id}/branches/{branch_id}

Options

Global flags

Examples

The following example gets information about a branch:

Bash
databricks postgres get-branch projects/my-project-id/branches/my-branch-id

databricks postgres get-endpoint

Get an Endpoint.

databricks postgres get-endpoint NAME [flags]

Arguments

NAME

    The name of the Endpoint to retrieve. Format: projects/{project_id}/branches/{branch_id}/endpoints/{endpoint_id}

Options

Global flags

Examples

The following example gets information about an endpoint:

Bash
databricks postgres get-endpoint projects/my-project-id/branches/my-branch-id/endpoints/my-endpoint-id

databricks postgres get-operation

Get an Operation.

databricks postgres get-operation NAME [flags]

Arguments

NAME

    The name of the operation resource.

Options

Global flags

Examples

The following example gets information about an operation:

Bash
databricks postgres get-operation projects/my-project-id/operations/my-operation-id

databricks postgres get-project

Get a Project.

databricks postgres get-project NAME [flags]

Arguments

NAME

    The name of the Project to retrieve. Format: projects/{project_id}

Options

Global flags

Examples

The following example gets information about a project:

Bash
databricks postgres get-project projects/my-project-id

databricks postgres list-branches

List Branches.

databricks postgres list-branches PARENT [flags]

Arguments

PARENT

    The Project that owns this collection of branches. Format: projects/{project_id}

Options

--page-size int

    Upper bound for items returned.

--page-token string

    Page token from a previous response.

Global flags

Examples

The following example lists all branches in a project:

Bash
databricks postgres list-branches projects/my-project-id

The following example lists branches with pagination:

Bash
databricks postgres list-branches projects/my-project-id --page-size 10

databricks postgres list-endpoints

List Endpoints.

databricks postgres list-endpoints PARENT [flags]

Arguments

PARENT

    The Branch that owns this collection of endpoints. Format: projects/{project_id}/branches/{branch_id}

Options

--page-size int

    Upper bound for items returned.

--page-token string

    Page token from a previous response.

Global flags

Examples

The following example lists all endpoints in a branch:

Bash
databricks postgres list-endpoints projects/my-project-id/branches/my-branch-id

The following example lists endpoints with pagination:

Bash
databricks postgres list-endpoints projects/my-project-id/branches/my-branch-id --page-size 10

databricks postgres list-projects

List Projects.

databricks postgres list-projects [flags]

Options

--page-size int

    Upper bound for items returned.

--page-token string

    Page token from a previous response.

Global flags

Examples

The following example lists all projects:

Bash
databricks postgres list-projects

The following example lists projects with pagination:

Bash
databricks postgres list-projects --page-size 10

databricks postgres update-branch

Update a Branch.

note

This is a long-running operation. By default, the command waits for the operation to complete. Use --no-wait to return immediately with the raw operation details. The operation's name field can then be used to poll for completion using the get-operation command.

databricks postgres update-branch NAME UPDATE_MASK [flags]

Arguments

NAME

    The resource name of the branch. Format: projects/{project_id}/branches/{branch_id}

UPDATE_MASK

    The list of fields to update. If unspecified, all fields are updated when possible.

Options

--json JSON

    The inline JSON string or the @path to the JSON file with the request body.

--name string

    The resource name of the branch.

--no-wait

    Don't wait to reach DONE state.

--timeout duration

    Maximum amount of time to reach DONE state.

Global flags

Examples

The following example updates a branch to make it protected:

Bash
databricks postgres update-branch projects/my-project-id/branches/my-branch-id spec.is_protected \
--json '{
"spec": {
"is_protected": true
}
}'

databricks postgres update-endpoint

Update an Endpoint.

note

This is a long-running operation. By default, the command waits for the operation to complete. Use --no-wait to return immediately with the raw operation details. The operation's name field can then be used to poll for completion using the get-operation command.

databricks postgres update-endpoint NAME UPDATE_MASK [flags]

Arguments

NAME

    The resource name of the endpoint. Format: projects/{project_id}/branches/{branch_id}/endpoints/{endpoint_id}

UPDATE_MASK

    The list of fields to update. If unspecified, all fields are updated when possible.

Options

--json JSON

    The inline JSON string or the @path to the JSON file with the request body.

--name string

    The resource name of the endpoint.

--no-wait

    Don't wait to reach DONE state.

--timeout duration

    Maximum amount of time to reach DONE state.

Global flags

Examples

The following example updates an endpoint's maximum compute units:

Bash
databricks postgres update-endpoint projects/my-project-id/branches/my-branch-id/endpoints/my-endpoint-id spec.autoscaling_limit_max_cu \
--json '{
"spec": {
"autoscaling_limit_max_cu": 8.0
}
}'

The following example updates multiple fields (min and max compute units):

Bash
databricks postgres update-endpoint projects/my-project-id/branches/my-branch-id/endpoints/my-endpoint-id "spec.autoscaling_limit_min_cu,spec.autoscaling_limit_max_cu" \
--json '{
"spec": {
"autoscaling_limit_min_cu": 1.0,
"autoscaling_limit_max_cu": 8.0
}
}'

databricks postgres update-project

Update a Project.

note

This is a long-running operation. By default, the command waits for the operation to complete. Use --no-wait to return immediately with the raw operation details. The operation's name field can then be used to poll for completion using the get-operation command.

databricks postgres update-project NAME UPDATE_MASK [flags]

Arguments

NAME

    The resource name of the project. Format: projects/{project_id}

UPDATE_MASK

    The list of fields to update. If unspecified, all fields are updated when possible.

Options

--json JSON

    The inline JSON string or the @path to the JSON file with the request body.

--name string

    The resource name of the project.

--no-wait

    Don't wait to reach DONE state.

--timeout duration

    Maximum amount of time to reach DONE state.

Global flags

Examples

The following example updates a project's display name:

Bash
databricks postgres update-project projects/my-project-id spec.display_name \
--json '{
"spec": {
"display_name": "Updated Project Name"
}
}'

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