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.1.tar.gz (2.8 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.1-py3-none-any.whl (2.7 kB view details)

Uploaded Python 3

File details

Details for the file PyDataverseOps-0.1.1.tar.gz.

File metadata

  • Download URL: PyDataverseOps-0.1.1.tar.gz
  • Upload date:
  • Size: 2.8 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.1.tar.gz
Algorithm Hash digest
SHA256 86472a0ba886f987c29b79cd59301aa7073e225172de1844405c9740bb581c69
MD5 1d21f0ec4f3012ae2de8f54cd6638784
BLAKE2b-256 a81de516074119ce2e373b2a2cb413e705255a85b31d70792b809d691b1f0cc4

See more details on using hashes here.

File details

Details for the file PyDataverseOps-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: PyDataverseOps-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 2.7 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9667a3471d305ca51b3023b367d281ceb891f7016186438d519b49f75dd53ac3
MD5 29d5d1bcbc66f7ecfe859244844c0250
BLAKE2b-256 9676b72512c741f67e403d4ec619c30baa8f9d4db94ac4edf05f469c50bdd03f

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