Пример #1
0
 def setUp(self):
     global meta, table, engine
     engine = engines.reconnecting_engine()
     meta = MetaData(engine)
     table = Table('sometable', meta,
         Column('id', Integer, primary_key=True),
         Column('name', String(50)))
     meta.create_all()
     table.insert().execute(
         [{'id':i, 'name':'row %d' % i} for i in range(1, 100)]
     )
Пример #2
0
 def test_null_pool(self):
     engine = engines.reconnecting_engine(options=dict(poolclass=pool.NullPool))
     conn = engine.connect()
     self.assertEquals(conn.execute(select([1])).scalar(), 1)
     assert not conn.closed
     engine.test_shutdown()
     try:
         conn.execute(select([1]))
         assert False
     except tsa.exc.DBAPIError, e:
         if not e.connection_invalidated:
             raise
Пример #3
0
 def setUp(self):
     global meta, table, engine
     engine = engines.reconnecting_engine()
     meta = MetaData(engine)
     table = Table('sometable', meta, Column('id',
                                             Integer,
                                             primary_key=True),
                   Column('name', String(50)))
     meta.create_all()
     table.insert().execute([{
         'id': i,
         'name': 'row %d' % i
     } for i in range(1, 100)])
Пример #4
0
 def test_null_pool(self):
     engine = engines.reconnecting_engine(options=dict(
         poolclass=pool.NullPool))
     conn = engine.connect()
     self.assertEquals(conn.execute(select([1])).scalar(), 1)
     assert not conn.closed
     engine.test_shutdown()
     try:
         conn.execute(select([1]))
         assert False
     except tsa.exc.DBAPIError, e:
         if not e.connection_invalidated:
             raise
Пример #5
0
    def test_basic(self):
        for threadlocal in (False, True):
            engine = engines.reconnecting_engine(options={'pool_recycle':1, 'pool_threadlocal':threadlocal})
        
            conn = engine.contextual_connect()
            self.assertEquals(conn.execute(select([1])).scalar(), 1)
            conn.close()

            engine.test_shutdown()
            time.sleep(2)
    
            conn = engine.contextual_connect()
            self.assertEquals(conn.execute(select([1])).scalar(), 1)
            conn.close()
Пример #6
0
    def test_basic(self):
        for threadlocal in (False, True):
            engine = engines.reconnecting_engine(
                options={
                    'pool_recycle': 1,
                    'pool_threadlocal': threadlocal
                })

            conn = engine.contextual_connect()
            self.assertEquals(conn.execute(select([1])).scalar(), 1)
            conn.close()

            engine.test_shutdown()
            time.sleep(2)

            conn = engine.contextual_connect()
            self.assertEquals(conn.execute(select([1])).scalar(), 1)
            conn.close()
Пример #7
0
 def setUp(self):
     global engine
     engine = engines.reconnecting_engine()
Пример #8
0
 def setUp(self):
     global engine
     engine = engines.reconnecting_engine()