<commit_before># python-odata

A simple library for read/write access to OData services I hacked together.

- Supports OData version 4.0 (Not tested on anything else, really)
- Requires JSON format support from the service
- Pure Python
- Should work on both Python 2.x and 3.x


## Examples

### Reading data from service

This library mimics the SQLAlchemy API to some degree. Defining models is done
in a similar fashion:

    from odata import ODataService
    from odata.entity import declarative_base, StringProperty

    Base = declarative_base()

    class Customer(Base):
        __odata_collection__ = 'Customers'
        __odata_type__ = 'NorthwindModel.Customer'
    
        id = StringProperty('CustomerID', primary_key=True)
        name = StringProperty('CompanyName')
        contact_name = StringProperty('ContactName')
        contact_title = StringProperty('ContactTitle')
        address = StringProperty('Address')
        city = StringProperty('City')
        region = StringProperty('Region')
        postal_code = StringProperty('PostalCode')
        country = StringProperty('Country')
        phone = StringProperty('Phone')
        fax = StringProperty('Fax')

Creating the service object:

    url = 'http://services.odata.org/V3/Northwind/Northwind.svc/'
    NorthwindService = ODataService(url, Base)

Read a single entry from the collection:

    query = NorthwindService.query(Customer)
    customer1 = query.first()

Filter the entries:

    query.filter(Customer.city == 'Berlin')

    query.filter(Customer.contact_title.startswith('Sales'))

Order the entries:

    query.order_by(Customer.name.desc())

Iterate over the results:
<commit_msg>Update url<commit_after># python-odata

A simple library for read/write access to OData services I hacked together.

- Supports OData version 4.0 (Not tested on anything else, really)
- Requires JSON format support from the service
- Pure Python
- Should work on both Python 2.x and 3.x


## Examples

### Reading data from service

This library mimics the SQLAlchemy API to some degree. Defining models is done
in a similar fashion:

    from odata import ODataService
    from odata.entity import declarative_base, StringProperty

    Base = declarative_base()

    class Customer(Base):
        __odata_collection__ = 'Customers'
        __odata_type__ = 'NorthwindModel.Customer'
    
        id = StringProperty('CustomerID', primary_key=True)
        name = StringProperty('CompanyName')
        contact_name = StringProperty('ContactName')
        contact_title = StringProperty('ContactTitle')
        address = StringProperty('Address')
        city = StringProperty('City')
        region = StringProperty('Region')
        postal_code = StringProperty('PostalCode')
        country = StringProperty('Country')
        phone = StringProperty('Phone')
        fax = StringProperty('Fax')

Creating the service object:

    url = 'http://services.odata.org/V4/Northwind/Northwind.svc/'
    NorthwindService = ODataService(url, Base)

Read a single entry from the collection:

    query = NorthwindService.query(Customer)
    customer1 = query.first()

Filter the entries:

    query.filter(Customer.city == 'Berlin')

    query.filter(Customer.contact_title.startswith('Sales'))

Order the entries:

    query.order_by(Customer.name.desc())

Iterate over the results:

{'fraction_non_alphanumeric': 0.08941877794336811, 'fraction_numerical': 0.0035767511177347243, 'mean_word_length': 3.5722070844686646, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4056394', 'n_tokens_mistral': 946, 'n_tokens_neox': 901, 'n_words': 275}