Skip to content
Open
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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove if unused

Empty file.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 0,
"metadata": {
"application/vnd.databricks.v1+cell": {
"cellMetadata": {
"byteLimit": 2048000,
"rowLimit": 10000
},
"inputWidgets": {},
"nuid": "1247c05c-b447-4270-a9d2-d704eae0af9e",
"showTitle": true,
"tableResultSettingsMap": {},
"title": "Install and Restart Databricks SDK Library"
}
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"output_type": "stream",
"text": [
"\u001B[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\ngoogle-api-core 2.20.0 requires protobuf!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<6.0.0.dev0,>=3.19.5, but you have protobuf 6.33.2 which is incompatible.\ngrpcio-status 1.71.0 requires protobuf<6.0dev,>=5.26.1, but you have protobuf 6.33.2 which is incompatible.\nmlflow-skinny 2.21.3 requires protobuf<6,>=3.12.0, but you have protobuf 6.33.2 which is incompatible.\u001B[0m\u001B[31m\n\u001B[0m\u001B[43mNote: you may need to restart the kernel using %restart_python or dbutils.library.restartPython() to use updated packages.\u001B[0m\n"
]
}
],
"source": [
"%pip install -U -qqqq databricks-sdk\n",
"dbutils.library.restartPython()"
]
},
{
"cell_type": "code",
"execution_count": 0,
"metadata": {
"application/vnd.databricks.v1+cell": {
"cellMetadata": {
"byteLimit": 2048000,
"rowLimit": 10000
},
"inputWidgets": {},
"nuid": "80b655ec-94f8-4933-b8a9-507726f11fa9",
"showTitle": true,
"tableResultSettingsMap": {},
"title": "Initialize WorkspaceClient in Databricks SDK"
}
},
"outputs": [],
"source": [
"from databricks.sdk import WorkspaceClient\n",
"\n",
"w = WorkspaceClient()"
]
},
{
"cell_type": "code",
"execution_count": 0,
"metadata": {
"application/vnd.databricks.v1+cell": {
"cellMetadata": {
"byteLimit": 2048000,
"rowLimit": 10000
},
"inputWidgets": {},
"nuid": "2d404a67-9778-403f-a3e2-180a12080f49",
"showTitle": true,
"tableResultSettingsMap": {},
"title": "Create and Wait for Database Instance in Databricks SDK"
}
},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"DatabaseInstance(name='bo-test-lakebase-3', capacity='CU_1', child_instance_refs=[], creation_time='2026-01-08T19:16:22Z', creator='[email protected]', custom_tags=[], effective_capacity='CU_1', effective_custom_tags=[], effective_enable_pg_native_login=True, effective_enable_readable_secondaries=False, effective_node_count=1, effective_retention_window_in_days=7, effective_stopped=False, effective_usage_policy_id=None, enable_pg_native_login=None, enable_readable_secondaries=None, node_count=None, parent_instance_ref=None, pg_version='PG_VERSION_16', read_only_dns='instance-ro-cd00746e-b544-45c8-9f08-5062a0858c7d.database.cloud.databricks.com', read_write_dns='instance-cd00746e-b544-45c8-9f08-5062a0858c7d.database.cloud.databricks.com', retention_window_in_days=None, state=<DatabaseInstanceState.AVAILABLE: 'AVAILABLE'>, stopped=None, uid='cd00746e-b544-45c8-9f08-5062a0858c7d', usage_policy_id=None)"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded value, consider parametrizing

]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from databricks.sdk.service.database import DatabaseInstance\n",
"from datetime import timedelta\n",
"\n",
"database_instance = DatabaseInstance(\n",
" name=\"bo-test-lakebase-3\",\n",
" capacity=\"CU_1\",\n",
" enable_pg_native_login=True,\n",
")\n",
"w.database.create_database_instance_and_wait(\n",
" database_instance=database_instance, timeout=timedelta(minutes=20)\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 0,
"metadata": {
"application/vnd.databricks.v1+cell": {
"cellMetadata": {
"byteLimit": 2048000,
"rowLimit": 10000
},
"inputWidgets": {},
"nuid": "5e800fad-2727-4bfb-835c-33f61e84a815",
"showTitle": false,
"tableResultSettingsMap": {},
"title": ""
}
},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"DatabaseInstanceRole(name='a797584d-d1b5-477b-bf00-947c57234d74', attributes=DatabaseInstanceRoleAttributes(bypassrls=False, createdb=False, createrole=False), effective_attributes=DatabaseInstanceRoleAttributes(bypassrls=False, createdb=False, createrole=False), identity_type=<DatabaseInstanceRoleIdentityType.SERVICE_PRINCIPAL: 'SERVICE_PRINCIPAL'>, instance_name='bo-test-lakebase-3', membership_role=<DatabaseInstanceRoleMembershipRole.DATABRICKS_SUPERUSER: 'DATABRICKS_SUPERUSER'>)"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from databricks.sdk.service.database import (\n",
" DatabaseInstanceRole,\n",
" DatabaseInstanceRoleAttributes,\n",
" DatabaseInstanceRoleIdentityType,\n",
" DatabaseInstanceRoleMembershipRole,\n",
")\n",
"\n",
"database_instance_role = DatabaseInstanceRole(\n",
" attributes=DatabaseInstanceRoleAttributes(\n",
" bypassrls=False,\n",
" createdb=False,\n",
" createrole=False,\n",
" ),\n",
" identity_type=DatabaseInstanceRoleIdentityType.SERVICE_PRINCIPAL,\n",
" membership_role=DatabaseInstanceRoleMembershipRole.DATABRICKS_SUPERUSER,\n",
" name=\"a797584d-d1b5-477b-bf00-947c57234d74\",\n",
")\n",
"w.database.create_database_instance_role(\n",
" instance_name=\"bo-test-lakebase-3\", database_instance_role=database_instance_role\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 0,
"metadata": {
"application/vnd.databricks.v1+cell": {
"cellMetadata": {
"byteLimit": 2048000,
"rowLimit": 10000
},
"inputWidgets": {},
"nuid": "491ba59f-142c-4067-8103-597660b0a681",
"showTitle": false,
"tableResultSettingsMap": {},
"title": ""
}
},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"DatabaseCatalog(name='bo-test-lakebase-catalog', database_instance_name='bo-test-lakebase-3', database_name='databricks_postgres', create_database_if_not_exists=True, uid=None)"
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from databricks.sdk.service.database import DatabaseCatalog\n",
"\n",
"w.database.create_database_catalog(\n",
" catalog=DatabaseCatalog(\n",
" name=\"bo-test-lakebase-catalog\",\n",
" database_instance_name=\"bo-test-lakebase-3\",\n",
" database_name=\"databricks_postgres\",\n",
" create_database_if_not_exists=True,\n",
" )\n",
")"
]
}
],
"metadata": {
"application/vnd.databricks.v1+notebook": {
"computePreferences": {
"hardware": {
"accelerator": null,
"gpuPoolId": null,
"memory": null
}
},
"dashboards": [],
"environmentMetadata": {
"base_environment": "",
"environment_version": "3"
},
"inputWidgetPreferences": null,
"language": "python",
"notebookMetadata": {
"pythonIndentUnit": 2
},
"notebookName": "01-lakebase-instance-setup",
"widgets": {}
},
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Loading