Skip to content

Use platform ?sql param for SQL SELECT#14

Merged
tpellissier-msft merged 2 commits intomainfrom
user/tpellissier/querysql-use-dv-endpoint
Oct 7, 2025
Merged

Use platform ?sql param for SQL SELECT#14
tpellissier-msft merged 2 commits intomainfrom
user/tpellissier/querysql-use-dv-endpoint

Conversation

@tpellissier-msft
Copy link
Copy Markdown
Contributor

Platform PR for ?sql param: https://dev.azure.com/dynamicscrm/OneCRM/_git/CDS/pullrequest/1428003

Copilot Summary:

This pull request updates the SDK to use the native Dataverse Web API ?sql= parameter for read-only SQL queries, replacing the previous approach that routed SQL through a custom API (McpExecuteSqlQuery). The documentation, code comments, and method implementations have been revised accordingly. The changes also improve error handling, clarify supported SQL syntax, and update the quickstart examples to reflect the new approach.

Key changes:

1. Migration from Custom API to Web API for SQL queries

  • The query_sql method in DataverseClient and its underlying implementation now execute SQL queries using the Dataverse Web API's ?sql= parameter, rather than posting to a custom API endpoint. This includes parsing the SQL to extract the logical table name, resolving it to an entity set, and issuing a GET request with the SQL as a query parameter. Error handling is enhanced, and only a constrained subset of SQL is supported. (src/dataverse_sdk/client.py, src/dataverse_sdk/odata.py) [1] [2]

2. Documentation and example updates

  • All references in README.md and example scripts have been updated to describe and demonstrate SQL queries via the Web API ?sql= parameter, removing mentions of the custom API and clarifying the supported SQL subset. (README.md, examples/quickstart.py, examples/quickstart_pandas.py) [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]

3. Removal of obsolete configuration

  • The sql_api_name property has been removed from DataverseConfig, as it is no longer needed for SQL queries. (src/dataverse_sdk/config.py) [1] [2]

4. Pandas wrapper adjustments

  • The query_sql_df method in the pandas wrapper now uses the Web API approach and updates its docstrings and comments to match the new SQL query mechanism. (src/dataverse_sdk/odata_pandas_wrappers.py) [1] [2]

5. Improved entity set resolution and caching

  • Added a cache for logical-to-entity set name resolution in ODataClient, improving efficiency for repeated SQL queries. (src/dataverse_sdk/odata.py)

@tpellissier-msft tpellissier-msft force-pushed the user/tpellissier/querysql-use-dv-endpoint branch from 94adc28 to 6497d40 Compare October 6, 2025 17:47
Comment thread README.md Outdated
Comment thread src/dataverse_sdk/client.py
Comment thread src/dataverse_sdk/odata.py Outdated
Comment thread src/dataverse_sdk/odata.py Outdated
@tpellissier-msft tpellissier-msft merged commit db7ff4a into main Oct 7, 2025
3 checks passed
@zhaodongwang-msft zhaodongwang-msft deleted the user/tpellissier/querysql-use-dv-endpoint branch February 13, 2026 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants