A package used to mimic the functionality of the Dataverse SDK.
Project description
datapyrse
Overview
datapyrse
is a Python library designed to mimic the functionality of the Microsoft Dataverse SDK
Features
- Data Retrieval: Easily retrieve data from Dataverse entities.
- Data Manipulation: Perform CRUD operations on Dataverse data.
- Query Building: Build complex queries to filter and sort data.
- Integration: Seamlessly integrate with other data processing libraries.
Installation
To install datapyrse
, use pip:
pip install datapyrse
Usage
from uuid import UUID
import sys
from datapyrse import (
ServiceClient,
Entity,
EntityCollection,
EntityReference,
EntityReferenceCollection,
)
from datapyrse.query import QueryExpression, ColumnSet
from datapyrse.messages import (
RetrieveMultipleResponse,
RetrieveResponse,
CreateResponse,
DeleteResponse,
)
service: ServiceClient = ServiceClient(
tenant_id="YOUR_TENANT_ID",
resource_url="YOUR_RESOURCE_URL", # e.g. https://yourorg.crm.dynamics.com
)
if not service.is_ready:
print("Service not ready")
sys.exit(1)
# Retrieve multiple entities
query: QueryExpression = QueryExpression(
"new_tablename", ColumnSet(["new_name", "ownerid"])
)
rm_response: RetrieveMultipleResponse = service.retrieve_multiple(query)
entities: EntityCollection = rm_response.entities
if entities.entities:
for ent in entities.entities:
print(f"\nId: {ent.entity_id}")
for attribute in ent.attributes:
print(f" {attribute}: {ent.attributes[attribute]}")
print()
# Retrieve a single entity
r_response: RetrieveResponse = service.retrieve(
"new_tablename", UUID("YOUR_GUID"), ColumnSet(["new_name", "ownerid"])
)
entity: Entity = r_response.entity
# Create a new entity
new_entity: Entity = Entity("new_tablename")
new_entity["new_name"] = "New Entity"
user_id: UUID = UUID("USER_GUID")
new_entity["ownerid"] = EntityReference("systemuser", user_id)
c_response: CreateResponse = service.create(new_entity)
if c_response.entity.entity_id:
new_entity_id: UUID = c_response.entity.entity_id
# Delete an entity
d_response: DeleteResponse = service.delete(
entity_logical_name="new_tablename", entity_id=UUID("YOUR GUID")
)
if d_response.was_deleted is True:
print("Entity deleted")
# Associate
service.associate(
target=EntityReference(
entity_logical_name="new_tablename", entity_id=UUID("A_GUID")
),
related_entities=EntityReferenceCollection(
entity_logical_name="new_anothertablename",
entity_references=[
EntityReference(
entity_logical_name="new_anothertablename",
entity_id=UUID("ANOTHER_GUID"),
),
],
),
relationship_name="the_relationship_Schema_Name",
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
datapyrse-0.7.0.tar.gz
(39.9 kB
view details)
Built Distribution
datapyrse-0.7.0-py3-none-any.whl
(56.7 kB
view details)
File details
Details for the file datapyrse-0.7.0.tar.gz
.
File metadata
- Download URL: datapyrse-0.7.0.tar.gz
- Upload date:
- Size: 39.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f13cb05c8b26a7ce75c926f1bb7f66f7c6ff046a1b79d944196bee0c96ec5400 |
|
MD5 | 155d82f999a05cb01a22fb179851a518 |
|
BLAKE2b-256 | 26fcfd44f85b8cb4324aa7a2f27e54fe9329dee680ef23b9e57aec7946d63674 |
File details
Details for the file datapyrse-0.7.0-py3-none-any.whl
.
File metadata
- Download URL: datapyrse-0.7.0-py3-none-any.whl
- Upload date:
- Size: 56.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd7f67e7e98e912e546f53d03e3fba5e0038ca31b4d173b22b517d5abee8948a |
|
MD5 | 87ac1e68a2407d049acfb2d7c9248d49 |
|
BLAKE2b-256 | cfd2ac2b73908d946d6cd534800efada8c815b11ce739a31c89ef2b4968d5192 |