Aestate
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
aestate.opera.DBPool.pooled_db.PooledDB Class Reference
Inheritance diagram for aestate.opera.DBPool.pooled_db.PooledDB:
Inheritance graph
Collaboration diagram for aestate.opera.DBPool.pooled_db.PooledDB:
Collaboration graph

Public Member Functions

def __init__ (self, creator, mincached=0, maxcached=0, maxshared=0, maxconnections=0, blocking=False, maxusage=None, setsession=None, reset=True, failures=None, ping=1, *args, **kwargs)
 
def steady_connection (self)
 
def connection (self, shareable=True)
 
def dedicated_connection (self)
 
def unshare (self, con)
 
def cache (self, con)
 
def close (self)
 
def __del__ (self)
 

Static Public Attributes

 version = __version__
 

Private Member Functions

def _wait_lock (self)
 

Private Attributes

 _creator
 
 _kwargs
 
 _blocking
 
 _maxusage
 
 _setsession
 
 _reset
 
 _failures
 
 _ping
 
 _maxcached
 
 _maxshared
 
 _shared_cache
 
 _maxconnections
 
 _idle_cache
 
 _lock
 
 _connections
 

Detailed Description

Pool for DB-API 2 connections.

After you have created the connection pool, you can use
connection() to get pooled, steady DB-API 2 connections.

Definition at line 23 of file pooled_db.py.

Constructor & Destructor Documentation

◆ __init__()

def aestate.opera.DBPool.pooled_db.PooledDB.__init__ (   self,
  creator,
  mincached = 0,
  maxcached = 0,
  maxshared = 0,
  maxconnections = 0,
  blocking = False,
  maxusage = None,
  setsession = None,
  reset = True,
  failures = None,
  ping = 1,
args,
**  kwargs 
)
设置DB-API 2连接池。

creator:返回新的DB-API 2的任意函数
    连接对象或符合DB-API 2的数据库模块
mincached:池中空闲连接的初始数量
    (0表示启动时未建立连接)
maxcached:池中最大空闲连接数
    (0或无表示池大小不受限制)
maxshared:共享连接的最大数量
    (0或无表示所有连接都是专用的)
    当达到此最大数量时,连接为
    如果被要求共享,则将它们共享。
maxconnections:通常允许的最大连接数
    (0或无表示任意数量的连接)
blocking:确定超出最大值时的行为
    (如果将其设置为true,请阻止并等待,直到
    连接减少,否则将报告错误)
maxusage:单个连接的最大重用次数
    (0或无表示无限重用)
    当达到连接的最大使用次数时,
    连接将自动重置(关闭并重新打开)。
setsession:可用于准备的SQL命令的可选列表
    会话,例如[“将日期样式设置为...”,“将时区设置为...”]
reset:返回到池后应如何重置连接
    (对于以begin()开始的回滚事务,为False或None,
    出于安全考虑,总是发出回滚是正确的)
failures:可选的异常类或异常类的元组
    为此,应应用连接故障转移机制,
    如果默认值(OperationalError,InternalError)不足够
ping:确定何时应使用ping()检查连接
    (0 =无=永不,1 =默认=每当从池中获取时,
    2 =创建游标时,4 =执行查询时,
    7 =始终,以及这些值的所有其他位组合)
args,kwargs:应传递给创建者的参数
    函数或DB-API 2模块的连接构造函数


初始化配置
以下参数与PooledDB一致
:param creator:默认即可
:param maxconnections:默认即可
:param mincached:默认即可
:param maxcached:默认即可
:param maxshared:默认即可
:param blocking:默认即可
:param setsession:默认即可
:param ping:默认即可
:param host:数据库IP地址
:param port:端口
:param user:用户名,如root
:param password:密码
:param database:数据库名
:param charset:编码格式
:param POOL:使用自定义的PooledDB,不建议

Definition at line 32 of file pooled_db.py.

◆ __del__()

def aestate.opera.DBPool.pooled_db.PooledDB.__del__ (   self)
Delete the pool.

Definition at line 268 of file pooled_db.py.

Here is the call graph for this function:

Member Function Documentation

◆ _wait_lock()

def aestate.opera.DBPool.pooled_db.PooledDB._wait_lock (   self)
private
Wait until notified or report an error.

Definition at line 275 of file pooled_db.py.

Here is the caller graph for this function:

◆ cache()

def aestate.opera.DBPool.pooled_db.PooledDB.cache (   self,
  con 
)
Put a dedicated connection back into the idle cache.

Definition at line 231 of file pooled_db.py.

Here is the caller graph for this function:

◆ close()

def aestate.opera.DBPool.pooled_db.PooledDB.close (   self)
Close all connections in the pool.

Definition at line 246 of file pooled_db.py.

Here is the caller graph for this function:

◆ connection()

def aestate.opera.DBPool.pooled_db.PooledDB.connection (   self,
  shareable = True 
)
从连接池中获得稳定的缓存的DB-API 2连接。

 :param shareable:允许共享连接

Definition at line 154 of file pooled_db.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dedicated_connection()

def aestate.opera.DBPool.pooled_db.PooledDB.dedicated_connection (   self)
Alias for connection(shareable=False).

Definition at line 211 of file pooled_db.py.

Here is the call graph for this function:

◆ steady_connection()

def aestate.opera.DBPool.pooled_db.PooledDB.steady_connection (   self)
获得稳定的,未池化的DB-API 2连接.

Definition at line 148 of file pooled_db.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unshare()

def aestate.opera.DBPool.pooled_db.PooledDB.unshare (   self,
  con 
)
Decrease the share of a connection in the shared cache.

Definition at line 215 of file pooled_db.py.

Here is the call graph for this function:

Member Data Documentation

◆ _blocking

aestate.opera.DBPool.pooled_db.PooledDB._blocking
private

Definition at line 104 of file pooled_db.py.

◆ _connections

aestate.opera.DBPool.pooled_db.PooledDB._connections
private

Definition at line 137 of file pooled_db.py.

◆ _creator

aestate.opera.DBPool.pooled_db.PooledDB._creator
private

Definition at line 102 of file pooled_db.py.

◆ _failures

aestate.opera.DBPool.pooled_db.PooledDB._failures
private

Definition at line 108 of file pooled_db.py.

◆ _idle_cache

aestate.opera.DBPool.pooled_db.PooledDB._idle_cache
private

Definition at line 135 of file pooled_db.py.

◆ _kwargs

aestate.opera.DBPool.pooled_db.PooledDB._kwargs
private

Definition at line 103 of file pooled_db.py.

◆ _lock

aestate.opera.DBPool.pooled_db.PooledDB._lock
private

Definition at line 136 of file pooled_db.py.

◆ _maxcached

aestate.opera.DBPool.pooled_db.PooledDB._maxcached
private

Definition at line 119 of file pooled_db.py.

◆ _maxconnections

aestate.opera.DBPool.pooled_db.PooledDB._maxconnections
private

Definition at line 132 of file pooled_db.py.

◆ _maxshared

aestate.opera.DBPool.pooled_db.PooledDB._maxshared
private

Definition at line 123 of file pooled_db.py.

◆ _maxusage

aestate.opera.DBPool.pooled_db.PooledDB._maxusage
private

Definition at line 105 of file pooled_db.py.

◆ _ping

aestate.opera.DBPool.pooled_db.PooledDB._ping
private

Definition at line 109 of file pooled_db.py.

◆ _reset

aestate.opera.DBPool.pooled_db.PooledDB._reset
private

Definition at line 107 of file pooled_db.py.

◆ _setsession

aestate.opera.DBPool.pooled_db.PooledDB._setsession
private

Definition at line 106 of file pooled_db.py.

◆ _shared_cache

aestate.opera.DBPool.pooled_db.PooledDB._shared_cache
private

Definition at line 124 of file pooled_db.py.

◆ version

aestate.opera.DBPool.pooled_db.PooledDB.version = __version__
static

Definition at line 30 of file pooled_db.py.


The documentation for this class was generated from the following file: