Skip to main content
https://travis-ci.org/ginkgobioworks/curious.svg?branch=master

Curious traverses relationships in a relational database. Curious queries allow users to explore relationships among objects, traverse recursive relationships, and jump between loosely connected databases. Curious also provides a JSON interface to the objects. Users and programmers can use Curious queries in analysis scripts and applications.

Curious favors a data centric model of application construction; Curious queries expose normalized, relational data, reducing UI dependency on UI specific API end-points serving denormalized data. Changing what data an UI needs no longer requires changing the UI specific end-points.

Curious works well with deep data models with many relationships. A Curious query can traverse 10s of foreign key like relationships efficiently. Curious queries always operate on sets of objects, and can connect a small number of objects via a relationship to a large number of objects, then via another relationship from the large number of objects to a smaller set again. For example, Book to Authors to Country of Residence. Unlike GraphQL, Curious outputs relationships between objects, rather than an ever growing tree of JSON representations of the objects.

Example

Book.last(10) Book.author_set Author.country(continent__name="North America")

Query Language

The query language allows traversing models by identfying the relationships between them, through foreign keys in Django models, or arbitrary id-mapping functions. A Curious query is a space-separated set of terms, which connect models together by relationships.

Several kinds of “joins” are possible using these relationship primitives:

  • A traditional inner join Book Book.author_set

  • A left outer join: Book.last(10) ?(Book.author_set)

  • A recusrive join: Parent.children_*

Furthermore, at each stage in a join, filtering can happen:

  • Filtering by Django field lookups: Book Book.author_set(id__in=[2,3,4])

  • Filtering by subquery: Book +(Book.author_set(id__in=[2,3,4]))

  • Filtering by exclusive subquery Book -(Book.author_set(id__in=[2,3,4]))

Finally, relationships can generate counts:

  • Counting Book Book.author_set__count

Configuring Curious

import myapp.models
from curious import model_registry

def register():
  model_registry.register(myapp.models)

Then include register when your Django app boots up.

Using Curious

Turn off CSRF. Deploy it as a Django app.

Writing Customized Relationships

Use filter and deferred to real functions.

Development

Requires Docker. Spin up your container using the provided docker-compose.yml file and Makefile by running make image. This creates an image with a correct git configuration for your user, which makes it easy to release. All of the commands you should need to run are defined the Makefile as targets. All of the targets except for image, are meant to be run inside the Docker container, but can be run from the host machine by having -ext appended to them. For example, to run tests, you could either call make test from inside the container, or make test-ext from the host.

If you are modifying the static assets during development, they can be recompiled with the build_assets make task, or by calling python setup.py build_assets.

./make test-ext

Deployment

Deployment of tagged commits happens to PyPI automatically via Travis CI. To bump and deploy a new version, run make bump/[foo]-ext, where [foo] is major, minor, or patch. Then git push origin --tags master.

Metadata

Release files for curious 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for curious 1.2.0
File Size Uploaded
curious-1.2.0.tar.gz 1.8 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for curious 1.2.0
File Interpreter ABI Platform
curious-1.2.0-py2-none-any.whl Python 2 none any Details

Total release size: 3.7 MB

Release files / curious-1.2.0.tar.gz

Download URL curious-1.2.0.tar.gz
Size 1.8 MB
Tags Source
SHA-256 checksum
How to use checksums
9c02a3b5fdf3172b1bb3d3f8c59b5fd2d93776da99efc26f79d95f05e532e472
BLAKE2b-256 checksum
How to use checksums
190cb15807f2a98560fe9b728aa146ad545d95e225db2d7ed7872f399dc9f694
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / curious-1.2.0-py2-none-any.whl

Download URL curious-1.2.0-py2-none-any.whl
Size 1.9 MB
Tags Python 2
SHA-256 checksum
How to use checksums
dbf314c2d998bba3cdb375c7b4af732d57fbda95798bf32f9a6be3442dd2a8bf
BLAKE2b-256 checksum
How to use checksums
8281f0bb678a9a399c0b54edda5d10cd507508031965b51f4e3dd964b11a4e18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

1.1.0

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page