Пример #1
0
 def execute(self, context: 'Context') -> None:
     big_query_hook = BigQueryHook(
         gcp_conn_id=self.gcp_conn_id,
         delegate_to=self.delegate_to,
         location=self.location,
         impersonation_chain=self.impersonation_chain,
     )
     project_id, dataset_id, table_id = self.source_project_dataset_table.split(
         '.')
     BigQueryTableLink.persist(
         context=context,
         task_instance=self,
         dataset_id=dataset_id,
         project_id=project_id,
         table_id=table_id,
     )
     mssql_hook = MsSqlHook(mssql_conn_id=self.mssql_conn_id,
                            schema=self.database)
     for rows in bigquery_get_data(
             self.log,
             self.dataset_id,
             self.table_id,
             big_query_hook,
             self.batch_size,
             self.selected_fields,
     ):
         mssql_hook.insert_rows(
             table=self.mssql_table,
             rows=rows,
             target_fields=self.selected_fields,
             replace=self.replace,
         )
 def execute(self, context):
     mssql_hook = MsSqlHook(mssql_conn_id=self.mssql_conn_id,
                            schema=self.database)
     for rows in self._bq_get_data():
         mssql_hook.insert_rows(self.mssql_table,
                                rows,
                                replace=self.replace)
Пример #3
0
def insert_mssql_hook():
    mssql_hook = MsSqlHook(mssql_conn_id='airflow_mssql', schema='airflow')

    rows = [
        ('India', 'Asia'),
        ('Germany', 'Europe'),
        ('Argentina', 'South America'),
        ('Ghana', 'Africa'),
        ('Japan', 'Asia'),
        ('Namibia', 'Africa'),
    ]
    target_fields = ['name', 'continent']
    mssql_hook.insert_rows(table='Country',
                           rows=rows,
                           target_fields=target_fields)
Пример #4
0
 def execute(self, context: 'Context') -> None:
     big_query_hook = BigQueryHook(
         gcp_conn_id=self.gcp_conn_id,
         delegate_to=self.delegate_to,
         location=self.location,
         impersonation_chain=self.impersonation_chain,
     )
     mssql_hook = MsSqlHook(mssql_conn_id=self.mssql_conn_id, schema=self.database)
     for rows in bigquery_get_data(
         self.log,
         self.dataset_id,
         self.table_id,
         big_query_hook,
         self.batch_size,
         self.selected_fields,
     ):
         mssql_hook.insert_rows(
             table=self.mssql_table,
             rows=rows,
             target_fields=self.selected_fields,
             replace=self.replace,
         )