# 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 {#write_table}

```python
conn.write_table(workspace_id, lakehouse_id, table_name, rows, mode='Overwrite')
```

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.

```python
# -*- 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 {#load_table}

```python
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`.

```python
# -*- 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 {#wait_for_operation}

```python
conn.wait_for_operation(location, timeout=600, interval=2.0)
```

Waits until a long-running operation ends and returns its final state. `load_table` returns such a location, and `write_table` calls this method itself.

| 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.

```python
# -*- 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 {#list_tables}

```python
conn.list_tables(workspace_id, lakehouse_id)
```

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`.

```python
# -*- 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}
```

```json
{"tables": ["admissions", "appointments", "insurers", "inventory", "invoices", "locations", "occupancy", "staff"]}
```

## See also {#see-also}

- [Queries](https://zato.io/docs/dev/examples/cloud/fabric/api/queries.html) - Reading the tables back with SQL
- [Files](https://zato.io/docs/dev/examples/cloud/fabric/api/files.html) - Putting the files load\_table reads into the lakehouse
- [Loading data into tables](https://zato.io/docs/dev/examples/cloud/fabric/loading-tables.html) - A nightly append, a small table replaced and a file loaded

## Learn more {#learn-more}

- [Development documentation](https://zato.io/docs/dev/) - Everything about writing services, in one place
- [Requests and responses](https://zato.io/docs/dev/request-response/) - What a service receives, what it returns and how to shape both
- [Integration examples](https://zato.io/docs/dev/examples/) - Ready-made code for the systems you are likely to connect to
- [IDE and debugging](https://zato.io/docs/dev/ide/) - Write services in the Dashboard or in your own editor
- [Data models](https://zato.io/docs/dev/model/) - Declare inputs and outputs and have them validated for you
- [In-depth API tutorial](https://zato.io/tutorials/main/01.html) - The full platform tutorial, from installation to production patterns
