warcprox/README.rst

70 lines
1.7 KiB
ReStructuredText
Raw Normal View History

2015-10-30 15:33:11 -07:00
.. image:: https://travis-ci.org/nlevitt/rethinkstuff.svg?branch=master
:target: https://travis-ci.org/nlevitt/rethinkstuff
2017-02-23 16:07:14 -08:00
rethinkstuff
============
2017-02-23 16:07:14 -08:00
RethinkDB python library. Provides connection manager and ORM framework
(object-relational mapping, sometimes called ODM or OM for nosql databases).
2017-02-23 16:07:14 -08:00
Connection Manager
------------------
2017-02-23 16:07:14 -08:00
Three main purposes:
2017-02-23 16:07:14 -08:00
- round-robin connections among database servers
- make sure connections close at proper time
- retry retry-able queries on failure
2017-02-23 16:07:14 -08:00
Not currently a connection pool, because it doesnt keep any connections open.
Should be possible to implement connection pooling without changing the API.
2017-02-23 16:07:14 -08:00
Usage Example
~~~~~~~~~~~~~
2017-02-23 16:07:14 -08:00
::
2017-02-23 16:07:14 -08:00
import rethinkstuff
r = rethinkstuff.Rethinker(['db0.foo.com', 'db0.foo.com:38015', 'db1.foo.com'], 'my_db')
r.table('mytable').insert({'foo':'bar','baz':2}).run()
for result in r.table('mytable'):
print("result={}".format(result))
ORM
---
Simple yet powerful ORM system. *Does not enforce a schema.*
Usage Example
~~~~~~~~~~~~~
::
import rethinkstuff
2017-02-23 16:07:14 -08:00
r = rethinkstuff.Rethinker(['db0.foo.com', 'db0.foo.com:38015', 'db1.foo.com'], 'my_db')
2017-02-23 16:07:14 -08:00
class MyTable(rethinkstuff.Document):
pass
MyTable.table_create()
doc1 = MyTable(r, {'animal': 'elephant', 'size': 'large'})
doc1.save()
doc1_copy = MyTable.get(r, 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”.