Giter Club home page Giter Club logo

doublethink's Introduction

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.

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”.

doublethink's People

Contributors

nlevitt avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.