Exemplo n.º 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)]
     )
Exemplo n.º 2
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)]
     )
Exemplo n.º 3
0
 def test_null_pool(self):
     engine = engines.reconnecting_engine(options=dict(poolclass=pool.NullPool))
     conn = engine.connect()
     eq_(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
Exemplo n.º 4
0
 def test_null_pool(self):
     engine = engines.reconnecting_engine(options=dict(poolclass=pool.NullPool))
     conn = engine.connect()
     eq_(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
Exemplo n.º 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()
         eq_(conn.execute(select([1])).scalar(), 1)
         conn.close()
         engine.test_shutdown()
         time.sleep(2)
         conn = engine.contextual_connect()
         eq_(conn.execute(select([1])).scalar(), 1)
         conn.close()
Exemplo n.º 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()
            eq_(conn.execute(select([1])).scalar(), 1)
            conn.close()

            engine.test_shutdown()
            time.sleep(2)
    
            conn = engine.contextual_connect()
            eq_(conn.execute(select([1])).scalar(), 1)
            conn.close()
Exemplo n.º 7
0
 def setup(self):
     global engine
     engine = engines.reconnecting_engine()
Exemplo n.º 8
0
 def setup(self):
     global engine
     engine = engines.reconnecting_engine()