Exemplo n.º 1
0
    def __init__(self,
                 config,
                 minconn=5,
                 maxconn=10,
                 key='defalut',
                 adapter='mysql'):
        """ Setup DB::

        param config dict: is the db adapter config
        param key string: the key to identify dabtabase
        param adapter string: the dabtabase adapter current support mysql only
        param minconn int: the min connection for connection pool
        param maxconn int: the max connection for connection pool

        """
        adapter = adapter or 'mysql'
        self.key = key
        self.adapter = adapter
        self.pool = ConnectionPool(minconn, maxconn,
                                   self.connection_class(adapter), config)
        self.dialect = self.dialect_class(adapter)(self)