Metadata-Version: 2.1
Name: msfabricutils
Version: 0.1.3
Summary: A Python library exposes additional functionality to work with Python Notebooks in Microsoft Fabric.
Author: Jimmy Jensen
License: The MIT License (MIT)
        
        Copyright (c) [2024] [Jimmy Jensen]
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Project-URL: Repository, https://github.com/mrjsj/msfabricutils
Keywords: fabric,Microsoft,duckdb,deltalake
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: duckdb>=1.1.3
Requires-Dist: deltalake>=0.22.0
Requires-Dist: sqlglot>=25.32.1
Provides-Extra: sempy
Requires-Dist: semantic-link>=0.8.0; extra == "sempy"
Provides-Extra: docs
Requires-Dist: mkdocs==1.6.1; extra == "docs"
Requires-Dist: mkdocs-material==9.5.47; extra == "docs"
Requires-Dist: mkdocs-gen-files==0.5.0; extra == "docs"
Requires-Dist: mkdocstrings-python; extra == "docs"
Provides-Extra: dev
Requires-Dist: pytest>=6.2.5; extra == "dev"
Requires-Dist: ruff>=0.8.1; extra == "dev"

# MSFabricUtils
A collection of Spark-free Python utilities for working with Microsoft Fabric.
## Features
### DuckDB Connection Wrapper
Seamless integration between DuckDB and Microsoft Fabric Lakehouses
Cross-workspace and cross-lakehouse querying capabilities
Automatic table registration and authentication
Support for Delta Lake tables
Flexible table name referencing (1-part to 4-part names)
## Installation
```bash
pip install msfabricutils
```
## Quick Start
```python
from msfabricutils import FabricDuckDBConnection
# Initialize connection
access_token = notebookutils.credentials.getToken('storage')
conn = FabricDuckDBConnection(access_token=access_token)

# Register lakehouses from different workspaces
conn.register_workspace_lakehouses(
    workspace_id='12345678-1234-5678-1234-567812345678', # Sales workspace
    lakehouses=['sales']
)

conn.register_workspace_lakehouses(
    workspace_id='87654321-8765-4321-8765-432187654321', # Marketing workspace
    lakehouses=['marketing']
)

# Query across workspaces using fully qualified names
df = conn.sql("""
    SELECT
        c.customer_id,
        c.name,
        c.region,
        s.segment,
        s.lifetime_value
    FROM sales_workspace.sales.main.customers c
    JOIN marketing_workspace.marketing.main.customer_segments s
    ON c.customer_id = s.customer_id
    WHERE c.region = 'EMEA'
""").df()

# Write results back to a lakehouse
conn.write(df, 'sales.customer_segments_emea', workspace_id='12345678-1234-5678-1234-567812345678')
```

## Documentation
For detailed documentation, examples, and API reference, visit our [GitHub Pages documentation](https://mrjsj.github.io/msfabricutils/).

## Table Name Formats
The DuckDB Connection wrapper supports multiple table name formats (if unambiguous):
- 4-part: workspace.lakehouse.schema.table
- 3-part: lakehouse.schema.table
- 2-part: lakehouse.table
- 1-part: table

# Contributing
Contributions are welcome! Here are some ways you can contribute:
Report bugs and feature requests through GitHub issues
Submit pull requests for bug fixes or new features
Improve documentation
Share ideas for new utilities

# License
This project is licensed under the MIT License - see the LICENSE file for details.
