Forum Discussion
Ka13
Helper II
7 months agoWrite_delta in Fabric Python Notebook Error
Hi , I had question in Fabric Python Notebook while using the write_deltalake was getting Error. I want to write the Data from Pandas Dataframe in the Lakehouse Table - cust_test. Can yo...
- 7 months ago
Hello Ka13 I doubt you'd be able to import mssparkutils as it is a Spark utility and you're using a Python notebook.
Here's a code you can use in Python notebook -
import sempy.fabric as fabric def get_workspace_and_lakehouse_id(target_name="my_lakehouse"): # Workspace ID workspace_id = fabric.get_notebook_workspace_id() # List lakehouse items (your exact signature) items = fabric.list_items(type="Lakehouse", workspace=workspace_id) lakehouse_id = None # Loop through rows (your structure: it[0] = id, it[1] = name) for it in items.values: if it[1] == target_name: lakehouse_id = it[0] break return workspace_id, lakehouse_id print(get_workspace_and_lakehouse_id())
Ka13
Helper II
7 months agoAsmita_27 - thanks for your reply. How to get the workspace-id and Lakehouse-id in fabric python notebook? , to get the workspace-id and Lakehouse id and then pass it to url
deborshi_nag
Super User
7 months agoHello Ka13 I doubt you'd be able to import mssparkutils as it is a Spark utility and you're using a Python notebook.
Here's a code you can use in Python notebook -
import sempy.fabric as fabric
def get_workspace_and_lakehouse_id(target_name="my_lakehouse"):
# Workspace ID
workspace_id = fabric.get_notebook_workspace_id()
# List lakehouse items (your exact signature)
items = fabric.list_items(type="Lakehouse", workspace=workspace_id)
lakehouse_id = None
# Loop through rows (your structure: it[0] = id, it[1] = name)
for it in items.values:
if it[1] == target_name:
lakehouse_id = it[0]
break
return workspace_id, lakehouse_id
print(get_workspace_and_lakehouse_id())
- Ka137 months ago
Helper II
Thanks deborshi_nag for your response , tried above it's working.
Yes the mssparkutils did not worked in Python fabric notebook. - Ka137 months ago
Helper II
Thanks will test and let you know