Giter Site home page Giter Site logo

repool's Introduction

RethinkDB connection pool

repool is a Python library which provides a connection pool management for accessing a RethinkDB database. repool creates and maintains a configurable pool of active connection to a RethinkDB database. These connections are then available individually through a basic API.

Internally, repool uses the Python Queue class which is thread-safe. This means that the same connection pool can be share between several threads.

Installation

repool is available as a python library on Pypi. Installation is very simple using pip :

$ pip install repool

This will install repool as well as rethinkdb dependency.

Basic usage

A new connection pool using default connection configurations (host="localhost", port=28015, db="test", auth_key="", timeout=20) can simply be created by :

from repool import ConnectionPool

pool = ConnectionPool()
conn = pool.acquire()         #returns a Connection instance
r.table('heroes').run(conn)   #do RethinkDB stuff
# ...
pool.release(conn)          #put back connection to the pool
pool.release_pool()         #release pool (close rethinkdb connections)

Optional arguments

ConnectionPool creation accepts a number of optional arguments :

  • host, port, db, auth_key, timeout : which corresponds to rethinkdb connect() method.
  • pool_size : set the pool size, ie. the number of connections opened simultaneously (default=10).
  • conn_ttl : set the connection time to live. Connections older than TTL are automatically closed and re-opened by an internal thread (default=3600 seconds, set to 0 for disable)
  • cleanup: the interval between each pool cleanup for old connections (default=60 seconds)

repool's People

Contributors

imhoffd avatar

Stargazers

 avatar

Watchers

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