名称: cnxload 描述: 将文件(Parquet/CSV/JSON)加载到JDBC表
连接加载技能
直接从Parquet、CSV或JSON文件加载数据到JDBC数据库表。这提供了一种简单的方式将数据推入任何JDBC兼容的数据库,无需经过完整的Starlake加载管道。
使用方法
starlake cnxload [选项]
选项
--source_file <值>: 源文件的完整路径(必需)。支持Parquet、CSV、JSON--output_table <值>: 目标JDBC表,格式为模式.表(必需)--options k1=v1,k2=v2: JDBC连接选项:driver: JDBC驱动类(例如org.postgresql.Driver)user: 数据库用户password: 数据库密码url: JDBC URL(例如jdbc:postgresql://localhost:5432/mydb)partitions: 并行写入的分区数batchSize: 插入的批处理大小
--write_strategy <值>: 写入策略:APPEND、OVERWRITE--reportFormat <值>: 报告输出格式:console、json或html
示例
加载Parquet到PostgreSQL
starlake cnxload \
--source_file /data/orders.parquet \
--output_table public.orders \
--options driver=org.postgresql.Driver,url=jdbc:postgresql://localhost:5432/mydb,user=admin,password=secret \
--write_strategy APPEND
加载CSV到数据库
starlake cnxload \
--source_file /data/customers.csv \
--output_table public.customers \
--options driver=org.postgresql.Driver,url=jdbc:postgresql://localhost:5432/mydb,user=admin,password=secret \
--write_strategy OVERWRITE
加载带批处理选项
starlake cnxload \
--source_file /data/orders.parquet \
--output_table sales.orders \
--options driver=com.mysql.cj.jdbc.Driver,url=jdbc:mysql://localhost:3306/mydb,user=root,password=secret,batchSize=5000 \
--write_strategy APPEND