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 .

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 pydataverseops 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.0.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.0-py3-none-any.whl (2.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: PyDataverseOps-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 af1f2a2f3127b14856e33c0e400792994d086ec8da13fa54390cab39fb8ccbea
MD5 59b6ff29243ec6c378b1a2a500c7d725
BLAKE2b-256 395b804e9fa8639fdbd3fc589494a34ccbf43cb8a47a27fa9bf9f46128314b63

See more details on using hashes here.

File details

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

File metadata

  • Download URL: PyDataverseOps-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9a947e8152dbb05535f7903a8fe09d8d40553379b694a17ce705da877950b63f
MD5 6556b71f53fbdb9a2333b9406cdfbef7
BLAKE2b-256 3354ea2bc98568b06b1e5ba58b06532a9fefdaf6ff7976cfe179da07db0d2551

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