You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+71-36Lines changed: 71 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,9 +3,9 @@
3
3
A minimal Python SDK to use Microsoft Dataverse as a database for Azure AI Foundry–style apps.
4
4
5
5
- Read (SQL) — Execute constrained read-only SQL via the Dataverse Web API `?sql=` parameter. Returns `list[dict]`.
6
-
- OData CRUD — Thin wrappers over Dataverse Web API (create/get/update/delete).
7
-
- Bulk create — Pass a list of records to `create(...)` to invoke the bound `CreateMultiple` action; returns `list[str]` of GUIDs. If `@odata.type`is absent the SDK resolves the logical name from metadata (cached).
8
-
- Bulk update — Call `update_multiple(entity_set, records)` to invoke the bound `UpdateMultiple` action; returns nothing. Each record must include the real primary key attribute (e.g. `accountid`).
- Bulk create — Pass a list of records to `create(...)` to invoke the bound `CreateMultiple` action; returns `list[str]` of GUIDs. If any payload omits `@odata.type` the SDK resolves and stamps it (cached).
8
+
- Bulk update — Provide a list of IDs with a single patch (broadcast) or a list of per‑record patches to `update(...)`; internally uses the bound `UpdateMultiple` action; returns nothing. Each record must include the primary key attribute when sent to UpdateMultiple.
9
9
- Retrieve multiple (paging) — Generator-based `get_multiple(...)` that yields pages, supports `$top` and Prefer: `odata.maxpagesize` (`page_size`).
@@ -17,7 +17,7 @@ A minimal Python SDK to use Microsoft Dataverse as a database for Azure AI Found
17
17
- SQL-over-API: Constrained SQL (single SELECT with limited WHERE/TOP/ORDER BY) via native Web API `?sql=` parameter.
18
18
- Table metadata ops: create simple custom tables with primitive columns (string/int/decimal/float/datetime/bool) and delete them.
19
19
- Bulk create via `CreateMultiple` (collection-bound) by passing `list[dict]` to `create(entity_set, payloads)`; returns list of created IDs.
20
-
- Bulk update via `UpdateMultiple` by calling `update_multiple(entity_set, records)` with primary key attribute present in each record; returns nothing.
20
+
- Bulk update via `UpdateMultiple`(invoked internally) by calling unified `update(entity_set, ids, patch|patches)`; returns nothing.
21
21
- Retrieve multiple with server-driven paging: `get_multiple(...)` yields lists (pages) following `@odata.nextLink`. Control total via `$top` and per-page via `page_size` (Prefer: `odata.maxpagesize`).
22
22
- Optional pandas integration (`PandasODataClient`) for DataFrame based create / get / query.
23
23
@@ -26,6 +26,36 @@ Auth:
26
26
- You can pass any `azure.core.credentials.TokenCredential` you prefer; examples use `InteractiveBrowserCredential` for local runs.
27
27
- Token scope used by the SDK: `https://<yourorg>.crm.dynamics.com/.default` (derived from `base_url`).
# Multi-update (1:1) – list of patches matches list of IDs
143
+
client.update("accounts", ids, [
144
+
{"telephone1": "555-1200"},
145
+
{"telephone1": "555-1300"},
146
+
])
147
+
print({"multi_update": "ok"})
111
148
112
149
# Delete
113
150
client.delete("accounts", account_id)
@@ -119,7 +156,7 @@ for r in rows:
119
156
120
157
## Bulk create (CreateMultiple)
121
158
122
-
Pass a list of payloads to `create(entity_set, payloads)` to invoke the collection-bound `Microsoft.Dynamics.CRM.CreateMultiple` action. The method returns a `list[str]` of created record IDs.
159
+
Pass a list of payloads to `create(entity_set, payloads)` to invoke the collection-bound `Microsoft.Dynamics.CRM.CreateMultiple` action. The method returns `list[str]` of created record IDs.
123
160
124
161
```python
125
162
# Bulk create accounts (returns list of GUIDs)
@@ -133,34 +170,31 @@ assert isinstance(ids, list) and all(isinstance(x, str) for x in ids)
133
170
print({"created_ids": ids})
134
171
```
135
172
136
-
## Bulk update (UpdateMultiple)
173
+
## Multi-update (UpdateMultiple under the hood)
137
174
138
-
Use `update_multiple(entity_set, records)`for a transactional batch update. The method returns `None`.
175
+
Use the unified `update` method for both single and bulk scenarios:
-Each record must include the primary key attribute (e.g. `accountid`). No `id` alias yet.
155
-
-If any payload omits `@odata.type`, the logical name is resolved once and stamped (same as bulk create).
156
-
-Entire request fails (HTTP error) if any individual update fails; no partial success list is returned.
157
-
- If you need refreshed records post-update, issue individual `get` calls or a `get_multiple` query.
189
+
-Returns `None` (same as single update) to keep semantics consistent.
190
+
-Broadcast vs per-record determined by whether `changes`is a dict or list.
191
+
-Primary key attribute is injected automatically when constructing UpdateMultiple targets.
192
+
- If any payload omits `@odata.type`, it's stamped automatically (cached logical name lookup).
158
193
159
-
Notes:
160
-
- The bulk create response typically includes IDs only; the SDK returns the list of GUID strings.
161
-
- Single-record `create` still returns the full entity representation.
162
-
-`@odata.type` handling: If any payload in the list omits `@odata.type`, the SDK performs a one-time metadata query (`EntityDefinitions?$filter=EntitySetName eq '<entity_set>'`) to resolve the logical name, caches it, and stamps each missing item with `Microsoft.Dynamics.CRM.<logical>`. If **all** payloads already include `@odata.type`, no metadata call is made.
163
-
- The metadata lookup is per entity set and reused across subsequent multi-create calls in the same client instance (in-memory cache only).
194
+
Bulk create notes:
195
+
- Response includes only IDs; the SDK returns those GUID strings.
196
+
- Single-record `create` returns a one-element list of GUIDs.
197
+
- Metadata lookup for `@odata.type` is performed once per entity set (cached in-memory).
164
198
165
199
166
200
## Retrieve multiple with paging
@@ -267,7 +301,8 @@ client.delete_table("SampleItem") # delete the table
267
301
```
268
302
269
303
Notes:
270
-
-`create/update` return the full record using `Prefer: return=representation`.
304
+
-`create` always returns a list of GUIDs (length 1 for single input).
305
+
-`update` and `delete` return `None` for both single and multi.
271
306
- Passing a list of payloads to `create` triggers bulk create and returns `list[str]` of IDs.
272
307
- Use `get_multiple` for paging through result sets; prefer `select` to limit columns.
273
308
- For CRUD methods that take a record id, pass the GUID string (36-char hyphenated). Parentheses around the GUID are accepted but not required.
0 commit comments