"""MySQL Client for ows-accounting testing..""" from pymysql import connect from pymysql import cursors class MySQLClient: """MySQL Client for ows-accounting testing.""" def __init__(self, host, db, user, password): """Initialize MySQLClient class.""" self.db_host = host self.db_user = user self.db_password = password self.db_database = db def execute_query(self, query_string): """Execute a query, return results.""" connection = connect(host=self.db_host, user=self.db_user, password=self.db_password, db=self.db_database) cursor = connection.cursor(cursors.DictCursor) cursor.execute(query_string) data = cursor.fetchall() cursor.close() connection.close() return data