def test_conpy21(self): conn = mariadb.connection(default_file='default.cnf') cursor = conn.cursor() self.assertFalse(cursor.closed) conn.close() self.assertTrue(cursor.closed) del cursor, conn
def test_reconnect(self): new_conn = mariadb.connection(default_file='default.cnf') conn1_id = new_conn.connection_id self.connection.kill(conn1_id) new_conn.reconnect() conn2_id = new_conn.connection_id self.assertFalse(conn1_id == conn2_id) del new_conn
def test_ping(self): new_conn = mariadb.connection(default_file='default.cnf') id = new_conn.connection_id self.connection.kill(id) try: new_conn.ping() except mariadb.DatabaseError: pass del new_conn new_conn = mariadb.connection(default_file='default.cnf') new_conn.auto_reconnect = True id = new_conn.connection_id self.connection.kill(id) new_conn.ping() new_id = new_conn.connection_id self.assertTrue(id != new_id) del new_conn
def test_change_user(self): cursor = self.connection.cursor() cursor.execute("create or replace user foo@localhost") cursor.execute("GRANT ALL on test.* TO 'foo'@'localhost'") new_conn = mariadb.connection(default_file='default.cnf') new_conn.change_user("foo", "", "test") self.assertEqual("foo", new_conn.user) del new_conn cursor.execute("drop user foo@localhost") del cursor
def setUp(self): self.connection = mariadb.connection(default_file='default.cnf')