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


Python pool.manage函数代码示例

本文整理汇总了Python中sqlalchemy.pool.manage函数的典型用法代码示例。如果您正苦于以下问题:Python manage函数的具体用法?Python manage怎么用?Python manage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: testbadargs

    def testbadargs(self):
        manager = pool.manage(mock_dbapi)

        try:
            connection = manager.connect(None)
        except:
            pass
开发者ID:gajop,项目名称:springgrid,代码行数:7,代码来源:test_pool.py

示例2: __init__

    def __init__(self, host, database, user, password, debug=False):
        self.host = host
        self.database = database
        # 用于判断是否打印sql
        self.debug = debug

        args = {'database': database}
        if user is not None:
            args['user'] = user
        if password is not None:
            args['password'] = password

        pair = host.split(':')
        if len(pair) == 2:
            args['host'] = pair[0]
            args['port'] = int(pair[1])
        else:
            args['host'] = pair[0]
            args['port'] = 3388

        self.args = args
        self._db = None
        # 单位为秒
        self._db_operation_timeout = 300

        # 连接池
        self.conn_pool = pool.manage(
            MySQLdb, pool_size=20, max_overflow=40, timeout=self._db_operation_timeout, recycle=1800)

        self.reconnection()
开发者ID:wmroar,项目名称:datouyi,代码行数:30,代码来源:DB_Mysql.py

示例3: testnonthreadlocalmanager

    def testnonthreadlocalmanager(self):
        manager = pool.manage(mock_dbapi, use_threadlocal=False)

        connection = manager.connect("foo.db")
        connection2 = manager.connect("foo.db")

        self.assert_(connection.cursor() is not None)
        self.assert_(connection is not connection2)
开发者ID:chatch,项目名称:pinyin-toolkit,代码行数:8,代码来源:test_pool.py

示例4: test_non_thread_local_manager

    def test_non_thread_local_manager(self):
        manager = pool.manage(MockDBAPI(), use_threadlocal=False)

        connection = manager.connect('foo.db')
        connection2 = manager.connect('foo.db')

        self.assert_(connection.cursor() is not None)
        self.assert_(connection is not connection2)
开发者ID:kihon10,项目名称:sqlalchemy,代码行数:8,代码来源:test_pool.py

示例5: patch_postgresql

def patch_postgresql():
    try:
        from django.db.backends.postgresql_psycopg2 import base as pgsql_base
    except (ImproperlyConfigured, ImportError) as e:
        return

    if not hasattr(pgsql_base, "_Database"):
        pgsql_base._Database = pgsql_base.Database
        pgsql_base.Database = manage(pgsql_base._Database, **POOL_SETTINGS)
开发者ID:gto-web,项目名称:djorm-ext-pool,代码行数:9,代码来源:__init__.py

示例6: patch_oracle

def patch_oracle():
    try:
        from django.db.backends.oracle import base as oracle_base
    except (ImproperlyConfigured, ImportError) as e:
        return

    if not hasattr(oracle_base, "_Database"):
        oracle_base._Database = oracle_base.Database
        oracle_base.Database = manage(oracle_base._Database, **POOL_SETTINGS)
开发者ID:gto-web,项目名称:djorm-ext-pool,代码行数:9,代码来源:__init__.py

示例7: patch_sqlite3

def patch_sqlite3():
    try:
        from django.db.backends.sqlite3 import base as sqlite3_base
    except (ImproperlyConfigured, ImportError) as e:
        return

    if not hasattr(sqlite3_base, "_Database"):
        sqlite3_base._Database = sqlite3_base.Database
        sqlite3_base.Database = manage(sqlite3_base._Database, **POOL_SETTINGS)
开发者ID:gto-web,项目名称:djorm-ext-pool,代码行数:9,代码来源:__init__.py

示例8: testmanager

    def testmanager(self):
        manager = pool.manage(mock_dbapi, use_threadlocal=True)

        connection = manager.connect("foo.db")
        connection2 = manager.connect("foo.db")
        connection3 = manager.connect("bar.db")

        self.assert_(connection.cursor() is not None)
        self.assert_(connection is connection2)
        self.assert_(connection2 is not connection3)
开发者ID:chatch,项目名称:pinyin-toolkit,代码行数:10,代码来源:test_pool.py

示例9: testnonthreadlocalmanager

    def testnonthreadlocalmanager(self):
        manager = pool.manage(mock_dbapi, use_threadlocal = False)
        
        connection = manager.connect('foo.db')
        connection2 = manager.connect('foo.db')

        self.echo( "connection " + repr(connection))

        self.assert_(connection.cursor() is not None)
        self.assert_(connection is not connection2)
开发者ID:nakedible,项目名称:vpnease-l2tp,代码行数:10,代码来源:pool.py

示例10: testmanager

    def testmanager(self):
        manager = pool.manage(mock_dbapi, use_threadlocal=True)

        connection = manager.connect('foo.db')
        connection2 = manager.connect('foo.db')
        connection3 = manager.connect('bar.db')

        print "connection " + repr(connection)
        self.assert_(connection.cursor() is not None)
        self.assert_(connection is connection2)
        self.assert_(connection2 is not connection3)
开发者ID:gajop,项目名称:springgrid,代码行数:11,代码来源:test_pool.py

示例11: get_pool

def get_pool():
    "Creates one and only one pool using the configured settings."
    global MYSQLPOOL
    if MYSQLPOOL is None:
        backend = getattr(settings, 'MYSQLPOOL_BACKEND', MYSQLPOOL_BACKEND)
        backend = getattr(pool, backend)
        kwargs = getattr(settings, 'MYSQLPOOL_ARGUMENTS', {})
        kwargs.setdefault('poolclass', backend)
        # The user can override this, but set it by default for safety.
        kwargs.setdefault('recycle', MYSQLPOOL_TIMEOUT)
        MYSQLPOOL = pool.manage(OldDatabase, **kwargs)
    return MYSQLPOOL
开发者ID:namongk,项目名称:django-mysqlpool,代码行数:12,代码来源:base.py

示例12: _connect

 def _connect(self):
     if cfg['CFG_MISCUTIL_SQL_USE_SQLALCHEMY']:
         try:
             import sqlalchemy.pool as pool
             import MySQLdb as mysqldb
             mysqldb = pool.manage(mysqldb, use_threadlocal=True)
             connect = mysqldb.connect
         except ImportError:
             cfg['CFG_MISCUTIL_SQL_USE_SQLALCHEMY'] = False
             from MySQLdb import connect
     else:
         from MySQLdb import connect
     return connect
开发者ID:mhellmic,项目名称:b2share,代码行数:13,代码来源:dbquery.py

示例13: _get_pool

def _get_pool():
    """
    Private function to get the database pool instance, or create one if it's not available yet.

    :returns: The connection pool instance
    """
    global _pool

    if _pool is None:
        # FIXME: Use pool size and other parameters from config
        _pool = dbpool.manage(MySQLdb, pool_size=1, use_threadlocal=True)

    return _pool
开发者ID:alvabai,项目名称:trac-multiproject,代码行数:13,代码来源:db.py

示例14: test_manager_with_key

    def test_manager_with_key(self):
        class NoKws(object):
            def connect(self, arg):
                return MockConnection()

        manager = pool.manage(NoKws(), use_threadlocal=True)

        c1 = manager.connect('foo.db', sa_pool_key="a")
        c2 = manager.connect('foo.db', sa_pool_key="b")
        c3 = manager.connect('bar.db', sa_pool_key="a")

        assert c1.cursor() is not None
        assert c1 is not c2
        assert c1 is  c3
开发者ID:pshken,项目名称:sqlalchemy,代码行数:14,代码来源:test_pool.py

示例15: get_pool

def get_pool():
    """Create one and only one pool using the configured settings."""
    global MYSQLPOOL
    if MYSQLPOOL is None:
        backend_name = getattr(settings, "SHIELD_MYSQL_POOL_BACKEND", DEFAULT_BACKEND)
        backend = getattr(local_pool, backend_name)
        kwargs = getattr(settings, "SHIELD_MYSQL_POOL_ARGUMENTS", {})
        kwargs.setdefault("poolclass", backend)
        kwargs.setdefault("recycle", DEFAULT_POOL_TIMEOUT)
        MYSQLPOOL = sa_pool.manage(OldDatabase, **kwargs)
        setattr(MYSQLPOOL, "_pid", os.getpid())

    if getattr(MYSQLPOOL, "_pid", None) != os.getpid():
        sa_pool.clear_managers()
    return MYSQLPOOL
开发者ID:torpedoallen,项目名称:shield_mysql_pool,代码行数:15,代码来源:base.py


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