|
BatchDataFrameOperations
|
針對 DataFrame 的批次記錄操作包裝器。
提供 create、 update,以及 delete 接受 pandas.DataFrame / pandas.Series 輸入並將其轉換為標準字典,然後在批次排隊前完成。 這讓資料科學呼叫者能直接將 DataFrame 輸入批次,無需手動轉換。
透過 batch.dataframe 存取。
範例:
import pandas as pd
batch = client.batch.new()
df = pd.DataFrame([
{"name": "Contoso", "telephone1": "555-0100"},
{"name": "Fabrikam", "telephone1": "555-0200"},
])
batch.dataframe.create("account", df)
result = batch.execute()
|
|
BatchOperations
|
批次操作的命名空間(client.batch)。
透過 client.batch 存取。 用來 new 建立建構者 BatchRequest 。
範例:
batch = client.batch.new()
batch.records.create("account", {"name": "Fabrikam"})
result = batch.execute()
|
|
BatchQueryOperations
|
查詢操作。BatchRequest
鏡像 client.query 完全一樣:相同的方法名稱、相同的簽名。
所有方法回傳 None;結果透過 BatchResult。
不要直接實例化;使用 batch.query。
|
|
BatchRecordOperations
|
在 . 上記錄操作 BatchRequest。
鏡像 client.records:相同的方法名稱、相同的簽名。
所有方法都會回傳 None;結果可透過 BatchResult 後 execute方取得。
GA 方法: retrieve (單紀錄)與 list (多紀錄,單頁)。
get 已棄用 — 請改用 retrieve 。
不要直接實例化;使用 batch.records。
|
|
BatchRequest
|
用於建構與執行 Dataverse OData $batch 請求的建置器。
透過 new (client.batch.new()) 取得。 將 、 、 和 的運算recordstables相加,或選擇性地將寫入 changeset,然後呼叫 execute。dataframequery
操作依加的順序依序執行。 結果 BatchResult 是每個 HTTP 請求被 BatchItemResponse 派遣一個(有些操作會擴展為多個請求)。
Note
每批次最多 1000 次 HTTP 操作。
範例:
batch = client.batch.new()
batch.records.create("account", {"name": "Contoso"})
batch.tables.get("account")
with batch.changeset() as cs:
ref = cs.records.create("contact", {"firstname": "Alice"})
cs.records.update("account", account_id, {
"primarycontactid@odata.bind": ref
})
result = batch.execute()
|
|
BatchTableOperations
|
表格中繼資料操作。BatchRequest
鏡像 client.tables 完全一樣:相同的方法名稱、相同的簽名。
所有方法回傳 None;結果透過 BatchResult。
Note
tables.delete、tables.add_columns 和 tables.remove_columns
需要在 GET EntityDefinitions 進行元資料查詢
execute 是時候解決表格的 MetadataId。
這種查詢對來電者來說是透明的。
Note
tables.add_columns和tables.remove_columns各自產生一個
每欄批次項目,所以他們會貢獻多個項目到
responses。
不要直接實例化;使用 batch.tables。
|
|
ChangeSet
|
一個由單一記錄寫入操作組成的交易群組。
所有操作皆成功或被重新合併。 作為情境管理器或呼叫 records 直接新增操作。
不要直接實例化;使用 changeset。
範例:
with batch.changeset() as cs:
ref = cs.records.create("contact", {"firstname": "Alice"})
cs.records.update("account", account_id, {
"primarycontactid@odata.bind": ref
})
|
|
ChangeSetRecordOperations
|
記錄寫入操作可在 ChangeSet.
鏡像 client.records 功能,但僅限於單一紀錄表單(無法大量建立/更新/刪除)。 只允許寫入操作——在變更集內不允許 GET。
不要直接實例化;使用 ChangeSet.records。
|
|
DataFrameOperations
|
pandas DataFrame CRUD 操作的命名空間。
透過 client.dataframe 存取。 提供以 DataFrame 為導向的封裝器,包覆記錄層級的 CRUD 操作。
範例:
import pandas as pd
client = DataverseClient(base_url, credential)
# Query records as a DataFrame
df = client.dataframe.get("account", select=["name"], top=100)
# Create records from a DataFrame
new_df = pd.DataFrame([{"name": "Contoso"}, {"name": "Fabrikam"}])
new_df["accountid"] = client.dataframe.create("account", new_df)
# Update records
new_df["telephone1"] = ["555-0100", "555-0200"]
client.dataframe.update("account", new_df, id_column="accountid")
# Delete records
client.dataframe.delete("account", new_df["accountid"])
|
|
FileOperations
|
檔案操作的命名空間。
透過 client.files 存取。 提供 Dataverse 檔案欄位的檔案上傳操作。
範例:
client = DataverseClient(base_url, credential)
client.files.upload(
"account", account_id, "new_Document", "/path/to/file.pdf"
)
|
|
QueryOperations
|
用於查詢操作的命名空間。
透過 client.query 存取。 提供對 Dataverse 資料表的查詢與搜尋操作。
範例:
from PowerPlatform.Dataverse.models.filters import col
client = DataverseClient(base_url, credential)
# Fluent query builder (recommended)
for record in (client.query.builder("account")
.select("name", "revenue")
.where(col("statecode") == 0)
.order_by("revenue", descending=True)
.top(100)
.execute()):
print(record["name"])
# SQL query
rows = client.query.sql("SELECT TOP 10 name FROM account ORDER BY name")
for row in rows:
print(row["name"])
|
|
RecordOperations
|
用於記錄級 CRUD 操作的命名空間。
透過 client.records 存取。 提供對個別 Dataverse 記錄的建立、更新、刪除及取得操作。
範例:
client = DataverseClient(base_url, credential)
# Create a single record
guid = client.records.create("account", {"name": "Contoso Ltd"})
# Get a record
record = client.records.get("account", guid, select=["name"])
# Update a record
client.records.update("account", guid, {"telephone1": "555-0100"})
# Delete a record
client.records.delete("account", guid)
|
|
TableOperations
|
用於資料表層元資料操作的命名空間。
透過 client.tables 存取。 提供建立、刪除、檢查及列出 Dataverse 資料表,以及新增與移除欄位的操作。
範例:
client = DataverseClient(base_url, credential)
# Create a table
info = client.tables.create(
"new_Product",
{"new_Price": "decimal", "new_InStock": "bool"},
solution="MySolution",
)
# List tables
tables = client.tables.list()
# Get table info
info = client.tables.get("new_Product")
# Add columns
client.tables.add_columns("new_Product", {"new_Rating": "int"})
# Remove columns
client.tables.remove_columns("new_Product", "new_Rating")
# Delete a table
client.tables.delete("new_Product")
|