Skip to main content

Talk to On-Prem Dynamics CRM

Project description

PyDynamics

Client and Query Builder for On-Premise Microsoft Dynamics CRM.

Getting an Auth Token

The first task would be to fetch an authentication token. To do this pass your username and password to the token.get() function along with the URL of your CRM instance.

from pydynamics import token
tok = token.get('https://crm.domain.com/', 'DOMAIN\\username', 'password')

The returned token can then be used in subsequent client calls.

Create a client instance

Pass the token generated above to the Client constructor along with the API URL.

from pydynamics.client import Client
client = Client(tok, 'https://crm.domain.com/INSTANCE/api/data/v8.1/')

Building Queries

The package includes a query builder.

Select a single item

The below example returns a single contact record, selected on its GUID and selects 3 specific fields to return. the select() part is optional, a default field set will be returned if it is omitted.

from pydynamics.querybuilder import QueryBuilder
q = QueryBuilder('contacts').guid('1bf1c4cf-1ed1-e311-941c-0050568a018c').\
    select(['firstname','lastname', 'emailaddress1'])
result = client.select(q)

Select based on filters

The below example returns the first 2, based on the limit(), contacts that contain the string "flowplex" within the emailaddress1 field and implements ordering and return field selection.

from pydynamics.querybuilder import QueryBuilder
q = QueryBuilder('contacts').\
    filter('emailaddress1', 'contains', 'flowplex', 'str').\
    select(['firstname','lastname', 'emailaddress1']).\
    order(['lastname'],'asc').limit(0 ,2)
result = client.select(q)

Create a record

The below creates a contact entity with the data provided to the query builder. The GUID of the new item will be returned if successful.

from pydynamics.querybuilder import QueryBuilder
q = QueryBuilder('contacts').data({
    'firstname': 'Dan',
    'lastname': 'Test',
    'emailaddress1': 'dan@fdsdsds.com'
    })
guid = client.create(q)

Update a record

The below updates the firstname field on the specific contact record.

from pydynamics.querybuilder import QueryBuilder
q = QueryBuilder('contacts').guid('1bf1c4cf-1ed1-e311-941c-0050568a018c').\
    data({'firstname': 'Daniel'})
client.update(q)

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

pydynamics-0.0.10.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

pydynamics-0.0.10-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file pydynamics-0.0.10.tar.gz.

File metadata

  • Download URL: pydynamics-0.0.10.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for pydynamics-0.0.10.tar.gz
Algorithm Hash digest
SHA256 3fc6d1ced2128f3ff9d30084ff3afa1a9bd687e9208f8b4b5b15ec3d525046b6
MD5 75315e3c9fa60015c938404a910fd323
BLAKE2b-256 ce7ac33fae0c78ae3e8b65d933a152a58109efe6f1be391ff41457cba4eee78e

See more details on using hashes here.

File details

Details for the file pydynamics-0.0.10-py3-none-any.whl.

File metadata

  • Download URL: pydynamics-0.0.10-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for pydynamics-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 9225862a9779c50e0be28638393ef96caf19497eeaed9aa97547f3a2627b4e68
MD5 28fe29c645c660622c25b852bd75f96b
BLAKE2b-256 baf2577e2a02e28ad18478d4ae73a8d41315fb450847e0b2665ec820063fa964

See more details on using hashes here.

Supported by

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