Skip to content

Latest commit

Β 

History

History
122 lines (92 loc) Β· 4.6 KB

File metadata and controls

122 lines (92 loc) Β· 4.6 KB

PowerPlatform Dataverse Client Examples

This directory contains comprehensive examples demonstrating how to use the PowerPlatform-Dataverse-Client SDK for Python. The examples are organized in a progressive learning path: Install β†’ Learn β†’ Test.

πŸ“¦ Installation

Install the PowerPlatform Dataverse Client SDK:

pip install PowerPlatform-Dataverse-Client

πŸ“ Directory Structure

🌱 Basic Examples (basic/)

Start here for getting up and running with the SDK:

  • installation_example.py - START HERE 🎯

    • Package installation validation and import verification
    • Method availability checking and troubleshooting
    • Basic usage examples and code patterns
    • Optional interactive testing with real environment
    • Perfect for first-run validation after installation
  • functional_testing.py - TEST BASIC FUNCTIONALITY πŸ§ͺ

    • Simple functional testing in real Dataverse environments
    • Basic CRUD operations validation with clean patterns
    • Table creation and basic querying tests
    • Interactive cleanup and straightforward validation
    • Perfect for verifying SDK works in your environment

πŸ”¬ Advanced Examples (advanced/)

Deep-dive into production-ready patterns and specialized functionality:

  • walkthrough.py - COMPREHENSIVE DEMO πŸš€

    • Full SDK feature demonstration with production-ready patterns
    • Table creation with custom schemas and enums
    • Single and bulk CRUD operations with error handling
    • Advanced querying (SQL and OData) with paging
    • Column metadata management and multi-language support
    • Interactive cleanup and best practices
  • sql_examples.py - SQL QUERY END-TO-END πŸ”

    • Schema discovery before writing SQL (list_columns, list_relationships)
    • Full SQL capabilities: SELECT, WHERE, TOP, ORDER BY, LIKE, IN, BETWEEN
    • JOINs (INNER, LEFT, multi-table), GROUP BY, DISTINCT, aggregates
    • OFFSET FETCH for server-side pagination
    • SELECT * auto-expansion (SDK rewrites for server compatibility)
    • Polymorphic lookups via SQL (ownerid, customerid, createdby)
    • SQL read -> DataFrame transform -> SDK write-back (full round-trip)
    • SQL-driven bulk create, update, and delete patterns
    • SQL to DataFrame via client.dataframe.sql()
    • Limitations with SDK fallbacks (writes, subqueries, functions)
    • Complete reference table: SQL vs SDK method mapping
  • file_upload.py - FILE OPERATIONS πŸ“Ž

    • File upload to Dataverse file columns with chunking
    • Advanced file handling patterns

πŸš€ Getting Started

Follow this recommended progression for the best learning experience:

πŸ“‹ Step 1: Validate Installation

# Install the SDK and dependencies
pip install PowerPlatform-Dataverse-Client azure-identity

# Validate installation and imports
python examples/basic/installation_example.py

πŸ§ͺ Step 2: Test Basic Functionality (Optional)

# Basic functional testing in your environment
python examples/basic/functional_testing.py

πŸš€ Step 3: Master Advanced Features

# Comprehensive walkthrough with production patterns
python examples/advanced/walkthrough.py

# SQL queries end-to-end with SDK fallbacks for unsupported operations
python examples/advanced/sql_examples.py

🎯 Quick Start Recommendations

  • New to the SDK? β†’ Start with examples/basic/installation_example.py
  • Need to test/validate? β†’ Use examples/basic/functional_testing.py
  • Want to see all features? β†’ Run examples/advanced/walkthrough.py
  • Using SQL queries? β†’ Run examples/advanced/sql_examples.py
  • Building production apps? β†’ Study patterns in examples/advanced/walkthrough.py

πŸ“‹ Prerequisites

  • Python 3.10+
  • PowerPlatform-Dataverse-Client SDK installed (pip install PowerPlatform-Dataverse-Client)
  • Azure Identity credentials configured
  • Access to a Dataverse environment

πŸ”’ Authentication

All examples use Azure Identity for authentication. Common patterns:

  • InteractiveBrowserCredential for development and interactive scenarios
  • DeviceCodeCredential for development on headless systems
  • ClientSecretCredential for production services with service principals

πŸ“– Documentation

For detailed API documentation, visit: Dataverse SDK Documentation

🀝 Contributing

When adding new examples:

  1. Follow the existing code style and structure
  2. Include comprehensive comments and docstrings
  3. Add error handling and validation
  4. Update this README with your example
  5. Test thoroughly before submitting