Skip to main content

A Python library to facilitate operations on Microsoft Dataverse

Project description

pyDataverseOps Library

Overview

The pyDataverseOps library facilitates operations on Microsoft Dataverse, handling authentication, data manipulation, and batch operations. It's designed for developers needing to interface with Dataverse for creating, reading, updating, and deleting records.

Features

  • Authenticate with OAuth2.
  • Read and write data using pandas DataFrames.
  • Perform batch updates and deletes to optimize network use.

Installation

First, clone this repository to your local machine:

git clone  https://github.com/ray2199/pyDataverseOps.git
cd your-repository-folder

Then install the library using pip:

pip install pyDataverseOps

Requirements

  • Python 3.6+
  • pandas
  • requests

Configuration

Before using the pyDataverseOps library, you must configure it with your Dataverse access credentials and endpoint. Here are the steps and parameters required:

Parameters

  • domain: Your Dataverse domain.
  • tenant_id: Tenant ID for OAuth authentication.
  • client_id: Client ID for OAuth authentication.
  • client_secret: Client Secret for OAuth authentication.

Example Initialization

from dataverse_ops import pyDataverseOps

dv_ops = pyDataverseOps(
    domain='your_dataverse_domain',
    tenant_id='your_tenant_id',
    client_id='your_client_id',
    client_secret='your_client_secret'
)

This initializes your connection to Dataverse with the necessary authentication headers.

Usage Examples

Reading Data

Retrieve data from a Dataverse table with optional filtering and pagination:

Parameters

  • table_logical_name: Logical name of the Dataverse table.
  • filters: Optional dictionary for OData filter expressions.
  • pagination: Set to True to paginate results if your query exceeds one page.

Example

filters = {'statuscode': ('eq', 1)}  # Equality filter example
data = dv_ops.read_data('Contacts', filters=filters, pagination=True)
print(data)

Writing Data

Write data to a Dataverse table from a pandas DataFrame:

Parameters

  • table_logical_name: Logical name of the Dataverse table.
  • data_df: DataFrame where each row represents a new record.

Example

import pandas as pd

data_df = pd.DataFrame({
    'firstname': ['John', 'Jane'],
    'lastname': ['Doe', 'Doe']
})
dv_ops.write_data('Contacts', data_df)

Updating Records

Update existing records in a Dataverse table:

Parameters

  • table_logical_name: Logical name of the table.
  • unique_column: Column name that uniquely identifies each record.
  • data_df: DataFrame containing the updated data.

Example

update_data = pd.DataFrame({
    'contactid': ['guid1', 'guid2'],
    'new_field_value': [123, 456]
})
dv_ops.update_records('Contacts', 'contactid', update_data)

Deleting Records

Batch delete records from a Dataverse table based on their IDs:

Parameters

  • table_logical_name: Logical name of the table.
  • unique_column: Unique identifier column for the records.

Example

dv_ops.batch_delete_records('Contacts', 'contactid')

Contributions

We welcome contributions to improve this library. Please fork the repository, make your changes, and submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyDataverseOps-0.1.2.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyDataverseOps-0.1.2-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file pyDataverseOps-0.1.2.tar.gz.

File metadata

  • Download URL: pyDataverseOps-0.1.2.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.0

File hashes

Hashes for pyDataverseOps-0.1.2.tar.gz
Algorithm Hash digest
SHA256 e17b62402df75863439ef6ec7e24e536165ed7bfb2ef78e8c01128ad965135f2
MD5 9046511969bcaad42db8cf96f42533b0
BLAKE2b-256 d3b7ec1909b243e300e4ef4795eaabfe00141b022f7a664136a30b2f6a2cbacb

See more details on using hashes here.

File details

Details for the file pyDataverseOps-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pyDataverseOps-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.0

File hashes

Hashes for pyDataverseOps-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 77afb2becebcaf94404b5fe1435b420b51bdce4ba63673fec3d93866f81bde80
MD5 e8a30210c0c12ddb191541c460c0358e
BLAKE2b-256 811fa643335eabfeeb97378f26a93e0daca5b9137bb72ca2a315429770e71607

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page