# SAP Business Data Cloud SDK
# Table of Contents
- [Introduction](#introduction)
- [Installation](#installation)
- [Usage](#usage)
- [Creating a Databricks Client](#create-a-client)
- [Create or Update Share](#create-or-update-share)
- [Create or Update Share CSN](#create-or-update-share-csn)
- [Publish a Data Product](#publish-a-data-product)
- [Unpublish a Data Product](#unpublish-a-data-product)
## Introduction
With this SDK you can perform Business Data Cloud Connect operations such as:
* Create or update shares
* Create or update shares [CSN](https://sap.github.io/csn-interop-specification/)
* Publish or unpublish Data Products
[Open Resource Discovery](https://open-resource-discovery.github.io/specification/) (ORD) is a protocol that allows applications and services to self-describe their resources and capabilities.
It facilitates cross consumption of resources and capabilities between different systems through a common standard interface.
[Delta Sharing](https://delta.io/sharing/) (DS) is an open protocol for secure sharing of Delta tables.
SAP Business Data Cloud support Delta Sharing and allows user data sets, represented as *shares*, to be shared securely.
This document focus on describing how SAP Business Data Cloud SDK should be used to publish *shares* and [ORD Data Products](https://open-resource-discovery.github.io/specification/details/articles/data-product) for downstream consumption within SAP Business Data Cloud.
## Installation
To install this SDK use the following pip command:
```
pip install sap-bdc-connect-sdk
```
## Usage
### Create a client
```python
from bdc_connect_sdk.auth import BdcConnectClient
from bdc_connect_sdk.auth import DatabricksClient
databricks_client = DatabricksClient(dbutils)
bdc_connect_client = BdcConnectClient(databricks_client)
```
- `DatabricksClient` receives `dbutils` as a parameter, which is a Databricks utility that can be used inside the Databricks notebooks
- `BdcConnectClient` receives the `DatabricksClient` as a parameter to get information from the Databricks environment (e.g. secrets, api_token, workspace_url_base)
### Create or update share
A share is a mechanism for distributing and accessing data across different systems. Creating or updating a share involves including specific attributes, such as `@openResourceDiscoveryV1`, in the request body, aligning with the [Open Resource Discovery](https://open-resource-discovery.github.io/specification/) protocol. This procedure ensures that the share is properly structured and described according to specified standards, facilitating effective data sharing and management.
```python
from bdc_connect_sdk.auth import BdcConnectClient
from bdc_connect_sdk.auth import DatabricksClient
import json
with BdcConnectClient(DatabricksClient(dbutils)) as bdc_connect_client:
share_name = "<share-name>"
try:
share_body = {
"type": "REMOTE_SHARE",
"provider": {
"type": "FEDERATION",
"name": "databricks"
},
"@openResourceDiscoveryV1": {
"title": "<data-product-title>",
"shortDescription": "<data-product-short-description>",
"description": "<data-product-description>"
}
}
share_request_body = json.dumps(share_body)
catalog_response = bdc_connect_client.create_or_update_share(
share_name,
share_request_body
)
except Exception as ex:
print(f"Exception when creating or updating share(name={share_name}): {ex}\n")
```
### Create or update share CSN
The [CSN](https://sap.github.io/csn-interop-specification/) serves as a standardized format for configuring and describing shares within a network. To create or update the CSN for a share, it's advised to prepare the CSN content in a separate file and include this content in the request body. This approach ensures accuracy and compliance with the CSN interoperability specifications, facilitating consistent and effective share configuration across systems.
> **Note:** The CSN schema, can be efficiently generated using a dedicated script `generate_csn_template` available in `csn_generator` file. This script automates the creation of CSN content for Databricks environments based on a Databricks share.
```python
from bdc_connect_sdk.auth import BdcConnectClient
from bdc_connect_sdk.auth import DatabricksClient
from bdc_connect_sdk.utils import csn_generator
import json
with BdcConnectClient(DatabricksClient(dbutils)) as bdc_connect_client:
share_name = "<share-name>"
try:
csn_schema = csn_generator.generate_csn_template(share_name)
csn_schema_string = json.dumps(csn_schema)
csn_response = bdc_connect_client.create_or_update_share_csn(
share_name,
csn_schema_string
)
except Exception as ex:
print(f"Exception when creating or updating CSN for share(name={share_name}): {ex}\n")
```
If the generated CSN needs to be modified for any reason, it can be written to a file for editing, for example.
```python
from bdc_connect_sdk.utils import csn_generator
import json
share_name = "<share-name>"
csn_schema = csn_generator.generate_csn_template(share_name)
file_path = f"csn_{share_name}.json"
with open(file_path, "w") as csn_file:
csn_file.write(json.dumps(csn_schema, indent=2))
# change the file
with open(file_path, "r") as csn_file:
changed_csn_schema = csn_file.read()
csn_schema = changed_csn_schema
```
### Publish a Data Product
A Data Product is an abstraction that represents a type of data or data set within a system, facilitating easier management and sharing across different platforms. It bundles resources or API endpoints to enable efficient data access and utilization by integrated systems. Publishing a Data Product allows these systems to access and consume the data, ensuring seamless communication and resource sharing.
```python
from bdc_connect_sdk.auth import BdcConnectClient
from bdc_connect_sdk.auth import DatabricksClient
with BdcConnectClient(DatabricksClient(dbutils)) as bdc_connect_client:
share_name = "<share-name>"
try:
publish_response = bdc_connect_client.publish_data_product(
share_name,
)
except Exception as ex:
print(f"Exception when publishing data product for share(name={share_name}): {ex}\n")
```
### Unpublish a Data Product
Unpublishing a Data Product involves withdrawing access to the data, typically when it has been sufficiently consumed or is no longer desired to be shared. This action helps maintain control over data accessibility and ensures that sharing aligns with security and usage policies. By unpublishing, the system can effectively manage the lifecycle of data and its availability to other integrated platforms.
```python
from bdc_connect_sdk.auth import BdcConnectClient
from bdc_connect_sdk.auth import DatabricksClient
with BdcConnectClient(DatabricksClient(dbutils)) as bdc_connect_client:
share_name = "<share-name>"
try:
unpublish_response = bdc_connect_client.delete_share(
share_name,
)
except Exception as ex:
print(f"Exception when unpublishing data product for share(name={share_name}): {ex}\n")
```
Raw data
{
"_id": null,
"home_page": "https://www.sap.com",
"name": "sap-bdc-connect-sdk",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "SAP SAPBusinessDataCloud SAPBDC SAPBDCConnect",
"author": "SAP SE",
"author_email": null,
"download_url": null,
"platform": null,
"description": "# SAP Business Data Cloud SDK\n\n# Table of Contents\n\n- [Introduction](#introduction)\n- [Installation](#installation)\n- [Usage](#usage)\n - [Creating a Databricks Client](#create-a-client)\n - [Create or Update Share](#create-or-update-share)\n - [Create or Update Share CSN](#create-or-update-share-csn)\n - [Publish a Data Product](#publish-a-data-product)\n - [Unpublish a Data Product](#unpublish-a-data-product)\n\n## Introduction\n\nWith this SDK you can perform Business Data Cloud Connect operations such as:\n\n* Create or update shares\n* Create or update shares [CSN](https://sap.github.io/csn-interop-specification/)\n* Publish or unpublish Data Products\n\n[Open Resource Discovery](https://open-resource-discovery.github.io/specification/) (ORD) is a protocol that allows applications and services to self-describe their resources and capabilities.\nIt facilitates cross consumption of resources and capabilities between different systems through a common standard interface.\n\n[Delta Sharing](https://delta.io/sharing/) (DS) is an open protocol for secure sharing of Delta tables.\nSAP Business Data Cloud support Delta Sharing and allows user data sets, represented as *shares*, to be shared securely.\n\nThis document focus on describing how SAP Business Data Cloud SDK should be used to publish *shares* and [ORD Data Products](https://open-resource-discovery.github.io/specification/details/articles/data-product) for downstream consumption within SAP Business Data Cloud.\n\n## Installation\n\nTo install this SDK use the following pip command:\n\n```\npip install sap-bdc-connect-sdk\n```\n\n## Usage\n\n### Create a client\n\n```python\nfrom bdc_connect_sdk.auth import BdcConnectClient\nfrom bdc_connect_sdk.auth import DatabricksClient\n\ndatabricks_client = DatabricksClient(dbutils)\nbdc_connect_client = BdcConnectClient(databricks_client)\n```\n\n- `DatabricksClient` receives `dbutils` as a parameter, which is a Databricks utility that can be used inside the Databricks notebooks\n- `BdcConnectClient` receives the `DatabricksClient` as a parameter to get information from the Databricks environment (e.g. secrets, api_token, workspace_url_base)\n\n### Create or update share\n\nA share is a mechanism for distributing and accessing data across different systems. Creating or updating a share involves including specific attributes, such as `@openResourceDiscoveryV1`, in the request body, aligning with the [Open Resource Discovery](https://open-resource-discovery.github.io/specification/) protocol. This procedure ensures that the share is properly structured and described according to specified standards, facilitating effective data sharing and management.\n\n```python\nfrom bdc_connect_sdk.auth import BdcConnectClient\nfrom bdc_connect_sdk.auth import DatabricksClient\nimport json\n\nwith BdcConnectClient(DatabricksClient(dbutils)) as bdc_connect_client:\n share_name = \"<share-name>\"\n\n try:\n share_body = {\n \"type\": \"REMOTE_SHARE\",\n \"provider\": {\n \"type\": \"FEDERATION\",\n \"name\": \"databricks\"\n },\n \"@openResourceDiscoveryV1\": {\n \"title\": \"<data-product-title>\",\n \"shortDescription\": \"<data-product-short-description>\",\n \"description\": \"<data-product-description>\"\n }\n }\n\n share_request_body = json.dumps(share_body)\n\n catalog_response = bdc_connect_client.create_or_update_share(\n share_name,\n share_request_body\n )\n except Exception as ex:\n print(f\"Exception when creating or updating share(name={share_name}): {ex}\\n\")\n```\n\n### Create or update share CSN\n\nThe [CSN](https://sap.github.io/csn-interop-specification/) serves as a standardized format for configuring and describing shares within a network. To create or update the CSN for a share, it's advised to prepare the CSN content in a separate file and include this content in the request body. This approach ensures accuracy and compliance with the CSN interoperability specifications, facilitating consistent and effective share configuration across systems.\n\n> **Note:** The CSN schema, can be efficiently generated using a dedicated script `generate_csn_template` available in `csn_generator` file. This script automates the creation of CSN content for Databricks environments based on a Databricks share.\n\n```python\nfrom bdc_connect_sdk.auth import BdcConnectClient\nfrom bdc_connect_sdk.auth import DatabricksClient\nfrom bdc_connect_sdk.utils import csn_generator\nimport json\n\nwith BdcConnectClient(DatabricksClient(dbutils)) as bdc_connect_client:\n share_name = \"<share-name>\"\n\n try:\n csn_schema = csn_generator.generate_csn_template(share_name)\n csn_schema_string = json.dumps(csn_schema)\n\n csn_response = bdc_connect_client.create_or_update_share_csn(\n share_name,\n csn_schema_string\n )\n except Exception as ex:\n print(f\"Exception when creating or updating CSN for share(name={share_name}): {ex}\\n\")\n```\n\nIf the generated CSN needs to be modified for any reason, it can be written to a file for editing, for example.\n\n```python\nfrom bdc_connect_sdk.utils import csn_generator\nimport json\n\nshare_name = \"<share-name>\"\ncsn_schema = csn_generator.generate_csn_template(share_name)\n\nfile_path = f\"csn_{share_name}.json\"\nwith open(file_path, \"w\") as csn_file:\n csn_file.write(json.dumps(csn_schema, indent=2))\n\n# change the file\n\nwith open(file_path, \"r\") as csn_file:\n changed_csn_schema = csn_file.read()\n\ncsn_schema = changed_csn_schema\n```\n\n\n### Publish a Data Product\n\nA Data Product is an abstraction that represents a type of data or data set within a system, facilitating easier management and sharing across different platforms. It bundles resources or API endpoints to enable efficient data access and utilization by integrated systems. Publishing a Data Product allows these systems to access and consume the data, ensuring seamless communication and resource sharing.\n\n```python\nfrom bdc_connect_sdk.auth import BdcConnectClient\nfrom bdc_connect_sdk.auth import DatabricksClient\n\nwith BdcConnectClient(DatabricksClient(dbutils)) as bdc_connect_client:\n share_name = \"<share-name>\"\n\n try:\n publish_response = bdc_connect_client.publish_data_product(\n share_name,\n )\n except Exception as ex:\n print(f\"Exception when publishing data product for share(name={share_name}): {ex}\\n\")\n```\n\n### Unpublish a Data Product\n\nUnpublishing a Data Product involves withdrawing access to the data, typically when it has been sufficiently consumed or is no longer desired to be shared. This action helps maintain control over data accessibility and ensures that sharing aligns with security and usage policies. By unpublishing, the system can effectively manage the lifecycle of data and its availability to other integrated platforms.\n\n```python\nfrom bdc_connect_sdk.auth import BdcConnectClient\nfrom bdc_connect_sdk.auth import DatabricksClient\n\nwith BdcConnectClient(DatabricksClient(dbutils)) as bdc_connect_client:\n share_name = \"<share-name>\"\n\n try:\n unpublish_response = bdc_connect_client.delete_share(\n share_name,\n )\n except Exception as ex:\n print(f\"Exception when unpublishing data product for share(name={share_name}): {ex}\\n\")\n```\n\n",
"bugtrack_url": null,
"license": "SAP DEVELOPER LICENSE AGREEMENT",
"summary": "Python SDK for SAP Business Data Cloud",
"version": "1.0.12",
"project_urls": {
"Homepage": "https://www.sap.com"
},
"split_keywords": [
"sap",
"sapbusinessdatacloud",
"sapbdc",
"sapbdcconnect"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "dd6c35c9ce342ad6525f02d52fb2f21b7f9f1d97d151d578a56398b445fbe39c",
"md5": "f9978967b366dd0a0e6b1025cff79863",
"sha256": "0332f8a86381484826c6aa06c3dc864c5ae2018ee0a5a4dca8d288fc18dfdc10"
},
"downloads": -1,
"filename": "sap_bdc_connect_sdk-1.0.12-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f9978967b366dd0a0e6b1025cff79863",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 43811,
"upload_time": "2025-07-23T07:33:56",
"upload_time_iso_8601": "2025-07-23T07:33:56.978702Z",
"url": "https://files.pythonhosted.org/packages/dd/6c/35c9ce342ad6525f02d52fb2f21b7f9f1d97d151d578a56398b445fbe39c/sap_bdc_connect_sdk-1.0.12-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-23 07:33:56",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "sap-bdc-connect-sdk"
}