def test_cozydb_cozycursor_retry_select(self): cursor1 = CozyCursor(**self.db_args) thread_id1 = cursor1.connection.thread_id() # Kill connection of cursor1, test re-connect ability then cursor2 = CozyCursor(**self.db_args) cursor2.execute('kill %d' % thread_id1) # wait MySQL server for disconnecting killed connection time.sleep(0.02) cursor1.execute('select 1', retry=1) eq_(cursor1.fetchone(), (1,)) err_msg = 'Thread id did not change after re-connect, it should be' ok_(thread_id1 != cursor1.connection.thread_id(), err_msg)
def test_cozydb_cozycursor_retry_select(self): cursor1 = CozyCursor(**self.db_args) thread_id1 = cursor1.connection.thread_id() # Kill connection of cursor1, test re-connect ability then cursor2 = CozyCursor(**self.db_args) cursor2.execute('kill %d' % thread_id1) # wait MySQL server for disconnecting killed connection time.sleep(0.02) cursor1.execute('select 1', retry=1) eq_(cursor1.fetchone(), (1, )) err_msg = 'Thread id did not change after re-connect, it should be' ok_(thread_id1 != cursor1.connection.thread_id(), err_msg)
def test_cozydb_cozycursor_reconnect(self): cursor1 = CozyCursor(**self.db_args) thread_id1 = cursor1.connection.thread_id() # Kill connection of cursor1, test re-connect ability then cursor2 = CozyCursor(**self.db_args) cursor2.execute('kill %d' % thread_id1) # wait MySQL server for disconnecting killed connection time.sleep(0.02) try: cursor1.execute('select 1') except MySQLdb.OperationalError: pass else: ok_(False, '%r connection did not break, it should be' % cursor1) cursor1.execute('select 1') eq_(cursor1.fetchone(), (1,)) err_msg = 'Thread id did not change after re-connect, it should be' ok_(thread_id1 != cursor1.connection.thread_id(), err_msg)
def test_cozydb_cozycursor_reconnect(self): cursor1 = CozyCursor(**self.db_args) thread_id1 = cursor1.connection.thread_id() # Kill connection of cursor1, test re-connect ability then cursor2 = CozyCursor(**self.db_args) cursor2.execute('kill %d' % thread_id1) # wait MySQL server for disconnecting killed connection time.sleep(0.02) try: cursor1.execute('select 1') except MySQLdb.OperationalError: pass else: ok_(False, '%r connection did not break, it should be' % cursor1) cursor1.execute('select 1') eq_(cursor1.fetchone(), (1, )) err_msg = 'Thread id did not change after re-connect, it should be' ok_(thread_id1 != cursor1.connection.thread_id(), err_msg)
def test_cozydb_cozycursor_fetchone_dict(self): cursor = CozyCursor(**self.db_args) cursor.execute('select 1 as name') eq_(cursor.fetchone(as_dict=True), {'name': 1})
def test_cozydb_cozycursor(self): cursor = CozyCursor(**self.db_args) cursor.execute('select 1') eq_(cursor.fetchone(), (1,))
def test_cozydb_cozycursor(self): cursor = CozyCursor(**self.db_args) cursor.execute('select 1') eq_(cursor.fetchone(), (1, ))