当前位置: 首页>>代码示例>>Python>>正文


Python PooledDB.PooledDB方法代码示例

本文整理汇总了Python中DBUtils.PooledDB.PooledDB方法的典型用法代码示例。如果您正苦于以下问题:Python PooledDB.PooledDB方法的具体用法?Python PooledDB.PooledDB怎么用?Python PooledDB.PooledDB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBUtils.PooledDB的用法示例。


在下文中一共展示了PooledDB.PooledDB方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: init

# 需要导入模块: from DBUtils import PooledDB [as 别名]
# 或者: from DBUtils.PooledDB import PooledDB [as 别名]
def init(config):
	try:
		global __connection_pool
		__connection_pool = PooledDB(
				creator=MySQLdb,
				mincached=1,
				maxcached=20,
				host=config.db_host,
				port=config.db_port,
				user=config.db_user,
				passwd=config.db_pass,
				db=config.db_database,
				use_unicode=False,
				charset="utf8",
				cursorclass=DictCursor)

		return True
	except Exception as e:
		logger.exception(e,"Mysql数据库初始化失败:host=%s,user=%s,pass=%s,db=%s",config.db_host,config.db_user,config.db_pass,config.db_database)
		return False 
开发者ID:newsettle,项目名称:ns4_chatbot,代码行数:22,代码来源:db_helper.py

示例2: _connect_with_pooling

# 需要导入模块: from DBUtils import PooledDB [as 别名]
# 或者: from DBUtils.PooledDB import PooledDB [as 别名]
def _connect_with_pooling(self, keywords):
        def get_pooled_db():
            from DBUtils import PooledDB

            # In DBUtils 0.9.3, `dbapi` argument is renamed as `creator`
            # see Bug#122112

            if PooledDB.__version__.split('.') < '0.9.3'.split('.'):
                return PooledDB.PooledDB(dbapi=self.db_module, **keywords)
            else:
                return PooledDB.PooledDB(creator=self.db_module, **keywords)

        if getattr(self, '_pooleddb', None) is None:
            self._pooleddb = get_pooled_db()

        return self._pooleddb.connection() 
开发者ID:mqingyn,项目名称:torngas,代码行数:18,代码来源:basedb.py

示例3: _connect_with_pooling

# 需要导入模块: from DBUtils import PooledDB [as 别名]
# 或者: from DBUtils.PooledDB import PooledDB [as 别名]
def _connect_with_pooling(self, keywords):
        def get_pooled_db():
            from DBUtils import PooledDB

            # In DBUtils 0.9.3, `dbapi` argument is renamed as `creator`
            # see Bug#122112
            
            if PooledDB.__version__.split('.') < '0.9.3'.split('.'):
                return PooledDB.PooledDB(dbapi=self.db_module, **keywords)
            else:
                return PooledDB.PooledDB(creator=self.db_module, **keywords)
        
        if getattr(self, '_pooleddb', None) is None:
            self._pooleddb = get_pooled_db()
        
        return self._pooleddb.connection() 
开发者ID:joxeankoret,项目名称:nightmare,代码行数:18,代码来源:db.py

示例4: __init__

# 需要导入模块: from DBUtils import PooledDB [as 别名]
# 或者: from DBUtils.PooledDB import PooledDB [as 别名]
def __init__(self, pool, shared_con):
        """Create a pooled shared connection.

        pool: the corresponding PooledDB instance
        con: the underlying SharedDBConnection

        """
        # basic initialization to make finalizer work
        self._con = None
        # proper initialization of the connection
        con = shared_con.con
        if not con.threadsafety() > 1:
            raise NotSupportedError("Database connection is not thread-safe.")
        self._pool = pool
        self._shared_con = shared_con
        self._con = con 
开发者ID:WebwareForPython,项目名称:DBUtils,代码行数:18,代码来源:PooledDB.py

示例5: __init__

# 需要导入模块: from DBUtils import PooledDB [as 别名]
# 或者: from DBUtils.PooledDB import PooledDB [as 别名]
def __init__(self):
        connkwargs = {
            'host': Config.MYSQL_CONFIG['HOST'],
            'user': Config.MYSQL_CONFIG['USER'],
            'port': Config.MYSQL_CONFIG['PORT'],
            'passwd': Config.MYSQL_CONFIG['PASSWORD'],
            'db': Config.MYSQL_CONFIG['NAME'],
            'charset': "utf8"
        }
        self._pool = PooledDB(MySQLdb, mincached=0, maxcached=10, maxshared=10, maxusage=10000, **connkwargs) 
开发者ID:LanceLRQ,项目名称:wejudge,代码行数:12,代码来源:base.py


注:本文中的DBUtils.PooledDB.PooledDB方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。