适用 KESTRA 获取CSV然后导入MYSQL

0
(0)

把CSV存好,放这里:

添加流程:

id: extract-load-mysql
namespace: company.team
variables:
  table: new
tasks:
  - id: extract
    type: io.kestra.plugin.core.http.Download
    uri: https://huggingface.co/datasets/kestra/datasets/raw/main/csv/orders.csv
  - id: enable_local_files
    type: io.kestra.plugin.jdbc.mysql.Query
    sql: SET GLOBAL local_infile=1;
  - id: create_table
    type: io.kestra.plugin.jdbc.mysql.Query
    sql: |
      create table if not exists {{ vars.table }}
      (
          order_id       integer,
          customer_name  varchar(50),
          customer_email varchar(50),
          product_id     integer,
          price          real,
          quantity       integer,
          total          real
      );
  - id: load_data
    type: io.kestra.plugin.jdbc.mysql.Query
    inputFile: "{{ outputs.extract.uri }}"
    sql: |
      LOAD DATA LOCAL INFILE '{{ inputFile }}' 
      INTO TABLE {{ vars.table }} 
      FIELDS TERMINATED BY ','
      LINES TERMINATED BY '\n'
      IGNORE 1 ROWS;
pluginDefaults:
  - type: io.kestra.plugin.jdbc.mysql.Query
    values:
      url: jdbc:mysql://localhost:3307/test
      username: root
      password: "LALALLA"

执行

这篇文章有用吗?

平均评分 0 / 5. 投票数: 0

到目前为止还没有投票!成为第一位评论此文章。

很抱歉,这篇文章对您没有用!

让我们改善这篇文章!

告诉我们我们如何改善这篇文章?


了解 工作生活心情记忆 的更多信息

Subscribe to get the latest posts sent to your email.