def __init__(self, host, port, dbname, user, password, schema): """ Connection to databases use dsn for opening async socket. Each demon uses two connections: for notifier and queries """ dsn = DBConnection._get_dsn(host, port, dbname, user, password) self._ipoll = DBInteractionPool(dsn, pool_size=2, do_log=settings.DEBUG) self._schema = schema
def get_connection(self, poll_connections): dsn = "host={host} port={port} user={user} password={password} dbname={dbname}".format( host=settings.DATABASES['HOST'], port=settings.DATABASES['PORT'], user=settings.DATABASES['USER'], password=settings.DATABASES['PASSWORD'], dbname=settings.DATABASES['NAME']) return DBInteractionPool(dsn, pool_size=poll_connections, do_log=settings.DEBUG)
def init(self): #import logging #import traceback log = logging.getLogger("init") log.info("init start") self.central_conn_pool = DBInteractionPool( get_central_database_dsn(), pool_size=CENTRAL_DB_POOL_SIZE, do_log=True) self.redis = StrictRedis(host=REDIS_HOST, port=REDIS_PORT, db=REDIS_DB) self.memcached_client = memcache.Client(MEMCACHED_NODES) self.collection_lookup = CollectionLookup(self.memcached_client, self.central_conn_pool) log.info("init complete") self.init_complete.set(True)
def test_connect_nonexisting_db(self): with self.assertRaises(DBPoolConnectionException): dsn = "host=127.0.0.1 port=5432 user=postgres dbname=gdbpool_test_not_here" fail_ipool = DBInteractionPool(dsn, pool_size=1, do_log=False)
def setUp(self): print "\n================================================================================\nRunning: %s\n================================================================================" % ( self._testMethodName) self.ipool = DBInteractionPool(dsn, pool_size=16, do_log=True)