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
+72-37Lines changed: 72 additions & 37 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`).
10
10
- Upload files — Call `upload_file(entity_set, ...)` and a upload method will be auto picked (user can also overwrite the upload mode). See https://learn.microsoft.com/en-us/power-apps/developer/data-platform/file-column-data?tabs=sdk#upload-files
@@ -18,7 +18,7 @@ A minimal Python SDK to use Microsoft Dataverse as a database for Azure AI Found
18
18
- SQL-over-API: Constrained SQL (single SELECT with limited WHERE/TOP/ORDER BY) via native Web API `?sql=` parameter.
19
19
- Table metadata ops: create simple custom tables with primitive columns (string/int/decimal/float/datetime/bool) and delete them.
20
20
- Bulk create via `CreateMultiple` (collection-bound) by passing `list[dict]` to `create(entity_set, payloads)`; returns list of created IDs.
21
-
- Bulk update via `UpdateMultiple` by calling `update_multiple(entity_set, records)` with primary key attribute present in each record; returns nothing.
21
+
- Bulk update via `UpdateMultiple`(invoked internally) by calling unified `update(entity_set, ids, patch|patches)`; returns nothing.
22
22
- 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`).
23
23
- Upload files, using either a single request (supports file size up to 128 MB) or chunk upload under the hood
24
24
- Optional pandas integration (`PandasODataClient`) for DataFrame based create / get / query.
@@ -28,6 +28,36 @@ Auth:
28
28
- You can pass any `azure.core.credentials.TokenCredential` you prefer; examples use `InteractiveBrowserCredential` for local runs.
29
29
- Token scope used by the SDK: `https://<yourorg>.crm.dynamics.com/.default` (derived from `base_url`).
# Bulk update (1:1) – list of patches matches list of IDs
147
+
client.update("accounts", ids, [
148
+
{"telephone1": "555-1200"},
149
+
{"telephone1": "555-1300"},
150
+
])
151
+
print({"multi_update": "ok"})
115
152
116
153
# Delete
117
154
client.delete("accounts", account_id)
@@ -123,7 +160,7 @@ for r in rows:
123
160
124
161
## Bulk create (CreateMultiple)
125
162
126
-
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.
163
+
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.
127
164
128
165
```python
129
166
# Bulk create accounts (returns list of GUIDs)
@@ -137,34 +174,31 @@ assert isinstance(ids, list) and all(isinstance(x, str) for x in ids)
137
174
print({"created_ids": ids})
138
175
```
139
176
140
-
## Bulk update (UpdateMultiple)
177
+
## Bulk update (UpdateMultiple under the hood)
141
178
142
-
Use `update_multiple(entity_set, records)`for a transactional batch update. The method returns `None`.
179
+
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.
159
-
-If any payload omits `@odata.type`, the logical name is resolved once and stamped (same as bulk create).
160
-
-Entire request fails (HTTP error) if any individual update fails; no partial success list is returned.
161
-
- If you need refreshed records post-update, issue individual `get` calls or a `get_multiple` query.
193
+
-Returns `None` (same as single update) to keep semantics consistent.
194
+
-Broadcast vs per-record determined by whether `changes`is a dict or list.
195
+
-Primary key attribute is injected automatically when constructing UpdateMultiple targets.
196
+
- If any payload omits `@odata.type`, it's stamped automatically (cached logical name lookup).
162
197
163
-
Notes:
164
-
- The bulk create response typically includes IDs only; the SDK returns the list of GUID strings.
165
-
- Single-record `create` still returns the full entity representation.
166
-
-`@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.
167
-
- The metadata lookup is per entity set and reused across subsequent multi-create calls in the same client instance (in-memory cache only).
198
+
Bulk create notes:
199
+
- Response includes only IDs; the SDK returns those GUID strings.
200
+
- Single-record `create` returns a one-element list of GUIDs.
201
+
- Metadata lookup for `@odata.type` is performed once per entity set (cached in-memory).
168
202
169
203
## File upload
170
204
@@ -284,7 +318,8 @@ client.delete_table("SampleItem") # delete the table
284
318
```
285
319
286
320
Notes:
287
-
-`create/update` return the full record using `Prefer: return=representation`.
321
+
-`create` always returns a list of GUIDs (length 1 for single input).
322
+
-`update` and `delete` return `None` for both single and multi.
288
323
- Passing a list of payloads to `create` triggers bulk create and returns `list[str]` of IDs.
289
324
- Use `get_multiple` for paging through result sets; prefer `select` to limit columns.
290
325
- For CRUD methods that take a record id, pass the GUID string (36-char hyphenated). Parentheses around the GUID are accepted but not required.
@@ -302,7 +337,7 @@ VS Code Tasks
302
337
- No general-purpose OData batching, upsert, or association operations yet.
303
338
-`DeleteMultiple` not yet exposed.
304
339
- Minimal retry policy in library (network-error only); examples include additional backoff for transient Dataverse consistency.
305
-
- Entity naming conventions in Dataverse: for multi-create the SDK resolves logical names from entity set metadata.
340
+
- Entity naming conventions in Dataverse: for bulk create the SDK resolves logical names from entity set metadata.
0 commit comments