Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE
README.md
postgrest.py
setup.py

README.md

postgrest-pyclient

A Python client for Postgrest.

Install

pip install --process-dependency-links https://github.com/datrium/postgrest-pyclient/archive/master.zip#egg=postgrest

Example Usage

    import postgrest

    class MyTable(postgrest.Resource):
        _meta_table_name = 'my_table'

        @property
        def _get_or_create_keys(self):
            return ('col1',)

        @property
        def _pk_dict(self):
            return {'id': 'eq.%s' % self.id}

    class MyPostgrestAPI(postgrest.PostgrestAPI):
        resources = [MyTable]



    api = MyPostgrestAPI('http://my.server.com:3000')

    obj = api.MyTable.get({'id': 'eq.1'})

    objs = api.MyTable.filter({'id': 'lte.10', 'col1': 'eq.foo'})

    # filter accepts any syntax that is in postgrest http GET spec
    objs = api.MyTable.filter({
        'id': 'lte.10',
        'col1->obj->>property': 'like.*example*',
        'select': 'id,col1,col2',
        'order': 'id.asc'
    })

    # get_or_create, inspired by django's orm
    obj, created = api.MyTable.get_or_create({
        'col1': 'foo'
    })
You can’t perform that action at this time.