Python Microsoft Fabric API - Tables
write_table, load_table, list_tables and wait_for_operation, with every parameter.
A connection has four methods for lakehouse tables. Every one takes the workspace ID and the lakehouse ID first.
write_table
Writes a list of dicts to a table and returns once the data is in it. The rows are written as CSV files to Files/zato/<table_name>/<timestamp>/ in the lakehouse, 100,000 rows per file, then loaded into the table in one operation that the call waits for.
| Parameter | Type | Meaning |
|---|---|---|
workspace_id | str | The workspace the lakehouse is in |
lakehouse_id | str | The lakehouse the table is in |
table_name | str | The table to write to, created if it does not exist |
rows | list of dict | The rows, all with the keys of the first one, which become the columns |
mode | str | Overwrite replaces the table with the rows, Append adds them to what is there |
Returns the completed operation as a dict, with status set to Succeeded. A load that fails raises an exception with the operation's details.
# -*- coding: utf-8 -*-
# Zato
from zato.server.service import Service
class WriteTable(Service):
def handle(self):
workspace_id = '11111111-2222-3333-4444-555555555555'
lakehouse_id = '66666666-7777-8888-9999-000000000000'
conn = self.microsoft.fabric['My Fabric']
rows = [
{'insurer_id': 'INS-01', 'name': 'Cascade Health Plan'},
{'insurer_id': 'INS-02', 'name': 'Pacific Mutual'},
{'insurer_id': 'INS-03', 'name': 'Evergreen Assurance'},
]
operation = conn.write_table(workspace_id, lakehouse_id, 'insurers', rows)
self.response.payload = {'status': operation['status']}
load_table
conn.load_table(workspace_id, lakehouse_id, table_name, relative_path, mode='Overwrite',
file_format='Csv', header=True, delimiter=',', path_type='File', recursive=False)
Starts loading a file or a folder that is already in the lakehouse's Files section into a table and returns right away, without waiting.
| Parameter | Type | Meaning |
|---|---|---|
workspace_id | str | The workspace the lakehouse is in |
lakehouse_id | str | The lakehouse the table and the file are in |
table_name | str | The table to load into, created if it does not exist |
relative_path | str | The file or folder, relative to the lakehouse, e.g. Files/incoming/admissions.csv |
mode | str | Overwrite or Append, as in write_table |
file_format | str | Csv or Parquet |
header | bool | CSV only - whether the first line holds the column names |
delimiter | str | CSV only - the character between values |
path_type | str | File when relative_path is one file, Folder when it is a folder of files |
recursive | bool | Folders only - whether to include files in subfolders |
Returns the address of the operation's status endpoint as a string, for wait_for_operation.
# -*- coding: utf-8 -*-
# Zato
from zato.server.service import Service
class LoadTable(Service):
def handle(self):
workspace_id = '11111111-2222-3333-4444-555555555555'
lakehouse_id = '66666666-7777-8888-9999-000000000000'
conn = self.microsoft.fabric['My Fabric']
location = conn.load_table(
workspace_id,
lakehouse_id,
'admissions',
'Files/incoming/admissions',
mode='Append',
file_format='Parquet',
path_type='Folder',
recursive=True,
)
self.response.payload = {'location': location}
wait_for_operation
Waits until a long-running operation ends and returns its final state. load_table is the method that returns such a location, and write_table calls this one on your behalf.
| Parameter | Type | Meaning |
|---|---|---|
location | str | The address load_table returned |
timeout | int | Seconds to wait before giving up |
interval | float | Seconds between checks |
Returns the operation as a dict with status set to Succeeded. An operation that fails raises an exception with its details, one that does not end within timeout raises an exception naming the location.
# -*- coding: utf-8 -*-
# Zato
from zato.server.service import Service
class LoadAndWait(Service):
def handle(self):
workspace_id = '11111111-2222-3333-4444-555555555555'
lakehouse_id = '66666666-7777-8888-9999-000000000000'
conn = self.microsoft.fabric['My Fabric']
location = conn.load_table(
workspace_id,
lakehouse_id,
'invoices',
'Files/incoming/payments-2026-03.csv',
mode='Append',
)
operation = conn.wait_for_operation(location, timeout=300)
self.response.payload = {'status': operation['status']}
list_tables
Returns every table of a lakehouse as a list of dicts, following Fabric's paging until there are no more.
| Parameter | Type | Meaning |
|---|---|---|
workspace_id | str | The workspace the lakehouse is in |
lakehouse_id | str | The lakehouse to list |
Each dict has name, type, location and format.
# -*- coding: utf-8 -*-
# Zato
from zato.server.service import Service
class ListTables(Service):
def handle(self):
workspace_id = '11111111-2222-3333-4444-555555555555'
lakehouse_id = '66666666-7777-8888-9999-000000000000'
conn = self.microsoft.fabric['My Fabric']
tables = conn.list_tables(workspace_id, lakehouse_id)
names = []
for table in tables:
names.append(table['name'])
self.response.payload = {'tables': names}
{"tables": ["admissions", "appointments", "insurers", "inventory", "invoices", "locations", "occupancy", "staff"]}
See also
| Page | What it covers |
|---|---|
| Queries | Reading the tables back with SQL |
| Files | Putting the files load_table reads into the lakehouse |
| Loading data into tables | These methods at work in the nightly load |