def test_should_record_records_with_kerberos_auth(self): conn_url = ( 'trino://[email protected]:7778/?' 'auth=kerberos&kerberos__service_name=HTTP&' 'verify=False&' 'protocol=https' ) with mock.patch.dict('os.environ', AIRFLOW_CONN_TRINO_DEFAULT=conn_url): hook = TrinoHook() sql = "SELECT name FROM tpch.sf1.customer ORDER BY custkey ASC LIMIT 3" records = hook.get_records(sql) assert [['Customer#000000001'], ['Customer#000000002'], ['Customer#000000003']] == records
def execute(self, context: Dict) -> None: trino = TrinoHook(trino_conn_id=self.trino_conn_id) self.log.info("Extracting data from Trino: %s", self.sql) results = trino.get_records(self.sql) mysql = MySqlHook(mysql_conn_id=self.mysql_conn_id) if self.mysql_preoperator: self.log.info("Running MySQL preoperator") self.log.info(self.mysql_preoperator) mysql.run(self.mysql_preoperator) self.log.info("Inserting rows into MySQL") mysql.insert_rows(table=self.mysql_table, rows=results)
def test_should_record_records(self): hook = TrinoHook() sql = "SELECT name FROM tpch.sf1.customer ORDER BY custkey ASC LIMIT 3" records = hook.get_records(sql) assert [['Customer#000000001'], ['Customer#000000002'], ['Customer#000000003']] == records