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)] )
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
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)])
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
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()
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()
def setUp(self): global engine engine = engines.reconnecting_engine()