Skip to content

PostgresDatabase

laktory.models.resources.databricks.PostgresDatabase ¤

Bases: PostgresDatabaseBase

Lakebase Autoscaling (Postgres) Database

Postgres database of a branch, owned by a role of the same branch. A databricks-postgres database is created implicitly with each branch: set replace_existing: true to manage it. Removing a managed database from the configuration deletes it. Can also be declared in the databases of a PostgresBranch.

Examples:

import io

from laktory import models

database_yaml = '''
parent: projects/app/branches/production
database_id: app-db
spec:
  postgres_database: app_db
  role: projects/app/branches/production/roles/app-owner
data_api:
  spec:
    db_schemas:
    - public
cdf_configs:
- postgres_schema: public
  catalog: dev
  schema: app_replicated
'''
database = models.resources.databricks.PostgresDatabase.model_validate_yaml(
    io.StringIO(database_yaml)
)
References
BASE DESCRIPTION
database_id

Part of the resource name

TYPE: str | None | VariableType DEFAULT: None

parent

Branch of the database (projects/{project_id}/branches/{branch_id}). Set automatically when declared in the databases of a branch.

TYPE: str | VariableType DEFAULT: None

provider_config

Configure the provider for management through account provider

TYPE: PostgresDatabaseProviderConfig | None | VariableType DEFAULT: None

replace_existing

If true, update the database if it already exists instead of returning an error

TYPE: bool | None | VariableType DEFAULT: None

spec

The desired state of the Database

TYPE: PostgresDatabaseSpec | None | VariableType DEFAULT: None

LAKTORY DESCRIPTION
cdf_configs

Change data feed configurations replicating schemas of the database into Unity Catalog. Their parent is set automatically.

TYPE: list[PostgresCdfConfig | VariableType] | VariableType DEFAULT: None

data_api

Data API exposing the database. Its parent is set automatically.

TYPE: PostgresDataApi | VariableType DEFAULT: None

METHOD DESCRIPTION
assign_parents

Set the database path on nested resources

ATTRIBUTE DESCRIPTION
additional_core_resources
  • data API

TYPE: list

path

Lakebase resource path {branch path}/databases/{database_id}

TYPE: str

additional_core_resources property ¤

  • data API
  • change data feed configurations

path property ¤

Lakebase resource path {branch path}/databases/{database_id}

assign_parents() ¤

Set the database path on nested resources

Source code in laktory/models/resources/databricks/postgresdatabase.py
72
73
74
75
76
77
78
79
80
@model_validator(mode="after")
def assign_parents(self):
    """Set the database path on nested resources"""
    if self.parent is None:
        return self
    for r in ([self.data_api] if self.data_api else []) + (self.cdf_configs or []):
        if r.parent is None:
            r.parent = self.path
    return self

laktory.models.resources.databricks.postgresdatabase.PostgresDatabaseProviderConfig ¤

Bases: BaseModel

PARAMETER DESCRIPTION
workspace_id

Workspace ID which the resource belongs to. This workspace must be part of the account which the provider is configured with

TYPE: str | None | VariableType DEFAULT: None


laktory.models.resources.databricks.postgresdatabase.PostgresDatabaseSpec ¤

Bases: BaseModel

PARAMETER DESCRIPTION
postgres_database

The name of the Postgres database

TYPE: str | None | VariableType DEFAULT: None

role

The name of the role that owns the database. Format: projects/{project_id}/branches/{branch_id}/roles/{role_id}

TYPE: str | VariableType