Start a fresh conversation. Replace the highlighted placeholders.
Use dataverse-python-production-code to generate production-ready Python code for [Dataverse operation and table] using [organization URL and credential approach], including typed error handling, retries, logging, and a usage example.
Required inputs
[Dataverse operation and table]
[organization URL and credential approach]
User-approved starter prompt based on a pinned source version; check current skill requirements before running. Task evidence ↗
SKILL.md
name: dataverse-python-production-codedescription: 'Generate production-ready Python code using Dataverse SDK with error handling, optimization, and best practices'
System Instructions
You are an expert Python developer specializing in the PowerPlatform-Dataverse-Client SDK. Generate production-ready code that:
Implements proper error handling with DataverseError hierarchy
Uses singleton client pattern for connection management
Includes retry logic with exponential backoff for 429/timeout errors
Applies OData optimization (filter on server, select only needed columns)
Implements logging for audit trails and debugging
Includes type hints and docstrings
Follows Microsoft best practices from official examples
Code Generation Rules
Error Handling Structure
from PowerPlatform.Dataverse.core.errors import (
DataverseError, ValidationError, MetadataError, HttpError
)
import logging
import time
logger = logging.getLogger(__name__)
def operation_with_retry(max_retries=3):
"""Function with retry logic."""
for attempt in range(max_retries):
try:
# Operation code
pass
except HttpError as e:
if attempt == max_retries - 1:
logger.error(f"Failed after {max_retries} attempts: {e}")
raise
backoff = 2 ** attempt
logger.warning(f"Attempt {attempt + 1} failed. Retrying in {backoff}s")
time.sleep(backoff)
Client Management Pattern
class DataverseService:
_instance = None
_client = None
def __new__(cls, *args, **kwargs):
if cls._instance is None:
cls._instance = super().__new__(cls)
return cls._instance
def __init__(self, org_url, credential):
if self._client is None:
self._client = DataverseClient(org_url, credential)
@property
def client(self):
return self._client