Skip to main content

rethinkdb python library

Project description

https://travis-ci.org/internetarchive/doublethink.svg?branch=master

doublethink

RethinkDB python library. Provides connection manager and ORM framework (object-relational mapping, sometimes called ODM or OM for nosql databases).

Connection Manager

Three main purposes:

  • round-robin connections among database servers

  • make sure connections close at proper time

  • retry retry-able queries on failure

Not currently a connection pool, because it doesn’t keep any connections open. Should be possible to implement connection pooling without changing the API. However, testing suggests there would be no appreciable performance gain from connection pooling.

Usage Example

import doublethink
rr = doublethink.Rethinker(['db0.foo.com', 'db0.foo.com:38015', 'db1.foo.com'], 'my_db')
rr.table('mytable').insert({'foo':'bar','baz':2}).run()
for result in rr.table('mytable'):
    print("result={}".format(result))

ORM

Simple yet powerful ORM system. Does not enforce a schema.

Usage Example

import doublethink

rr = doublethink.Rethinker(['db0.foo.com', 'db0.foo.com:38015', 'db1.foo.com'], 'my_db')

class MyTable(doublethink.Document):
    pass
MyTable.table_create(rr)

doc1 = MyTable(rr, {'animal': 'elephant', 'size': 'large'})
doc1.save()

doc1_copy = MyTable.load(rr, doc1.id)
doc1_copy.food = 'bread'
doc1_copy.save()

doc1.first_name = 'Frankworth'
doc1.save()

doc1.refresh()

Service Registry

Now also has a ServiceRegistry class, a lightweight solution for service discovery for distributed services. Maintains service info and status in a rethinkdb table called “services”.

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

doublethink-0.2.0.dev93.tar.gz (12.5 kB view details)

Uploaded Source

File details

Details for the file doublethink-0.2.0.dev93.tar.gz.

File metadata

  • Download URL: doublethink-0.2.0.dev93.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.5

File hashes

Hashes for doublethink-0.2.0.dev93.tar.gz
Algorithm Hash digest
SHA256 a63c2aaa07463c49772f92b27bf71a1ed4d75f0c4537d79f0a0d312ffad83915
MD5 e794d95e86142e3777974ebdff0c7a08
BLAKE2b-256 2d55038df6de20e8dc89a755a7bf4f58ae36fa558d9f7f350da3546785b7d29d

See more details on using hashes here.

Supported by

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