Skip to main content

Experimental ORM Query object

Project description

Summary

Experimental ORM Query object

The idea is to make RQL requests building simpler, and all with pythonic syntax.

It borrows a lot from the SQLAlchemy ORM.

Examples

Basic query with no filtering

::

CWUser = vreg[‘etypes’].etype_class(‘CWUser’) CWGroup = vreg[‘etypes’].etype_class(‘CWGroup’)

q = req.query(CWUser) assert q.torql(), (“Any X WHERE X is CWUser”, {})

q.all()

Same with attribute eagerloading:

q = req.query(CWUser).eagerload('login')

With filtering:

q = req.query(CWUser)
q = q.filter(CWUser.in_group.filter(CWGroup.name == u'managers'))

More complex filtering:

import datetime as dt

q = req.query(CWUser)
q = q.filter(
    (CWUser.creation_date >= dt.date.now() - dt.timedelta(30))
    & CWUser.in_group.filter(
        (CWGroup.name == u"users")))

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

rqlquery-0.2.0.tar.gz (7.1 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page