kettle从入门到精通 第八十课 ETL之kettle kettle中的json对象字段写入postgresql中的json字段

在Kettle中,要将JSON对象字段写入PostgreSQL,你可以使用JSON Input步骤来解析JSON数据,然后使用Table Output步骤将解析后的数据写入PostgreSQL数据库。以下是一个简化的转换示例:

  1. 首先,从文件或者之前的步骤中获取JSON数据。
  2. 使用JSON Input步骤解析JSON数据。
  3. 配置Table Output步骤连接PostgreSQL数据库,并将解析的字段映射到相应的数据库表字段。

以下是一个简单的转换流程:




JSON file input --> JSON Input --> Table Output

具体步骤如下:

  1. JSON file input中指定JSON文件的路径和要解析的JSON路径。
  2. JSON Input步骤中,选择之前定义的JSON文件输入,并指定字段的路径。
  3. Table Output步骤中,配置PostgreSQL数据库连接,选择目标数据库和表,并映射JSON Input步骤中解析出来的字段到数据库表字段。

请确保你已经安装了PostgreSQL的JDBC驱动,并在Kettle中配置了正确的数据库连接。

以下是一个简化的转换JSON对象字段并写入PostgreSQL的例子:




<transformation>
    <info>Transformation to read JSON, parse it and write to PostgreSQL</info>
    <steps>
        <step>
            <name>Get JSON from file</name>
            <type>JsonFileInput</type>
            <description/>
            <distribute>Y</distribute>
            <custom_distribution/>
            <cache_directory/>
            <readrowcount>0</readrowcount>
            <subtransformation/>
            <filefilename/>
            <encoding/>
            <rowlimit>0</rowlimit>
            <ignoreerrors>N</ignoreerrors>
            <file>
                <name>json_input</name>
                <accept_file_names>N</accept_file_names>
                <pass_through_fields>N</pass_through_fields>
                <accept_field_names>N</accept_field_names>
                <normaliser_enabled>N</normaliser_enabled>
                <running_in_parallel>N</running_in_parallel>
                <add_files_result>N</add_files_result>
                <is_in_fields>N</is_in_fields>
                <filefield>Filename</filefield>
                <file>
                    <name>filename1</name>
                    <filemask>*.json</filemask>
                    <exclude_filemask/>
                    <file_required>N</file_required>
                    <include_subfolders>N</include_subfolders>
                </file>
            </file>
            <fields>
                <!-- JSON input fields go here -->
            </fields>
            <limit>0</limit>
            <short_filename_field/>
            <path_field/>
            <is_repository_file>N</is_repository_file>
            <reset_between_parts>N</reset_between_parts>
            <ignore_transformation_absent>N</ignore_transformation_absent>
            <input_fields_prefix/>
        </step>
        <step>
 

评论已关闭

推荐阅读

Vue中使用mind-map实现在线思维导图
2024年08月04日
VUE
Web前端最全Vue实现免密登录跳转的方式_vue怎么样不登录返回首页,最强技术实现
2024年08月04日
VUE
vue3 项目搭建教程(基于create-vue,vite,Vite + Vue)
2024年08月04日
VUE
Vue-颜色选择器实现方案——>Vue-Color( 实战*1+ Demo*7)
2024年08月04日
VUE
Vue项目卡顿慢加载?这些优化技巧告诉你!_vue数据多渲染卡顿
2024年08月04日
VUE
vue中的keep-alive详解与应用场景
2024年08月04日
VUE
Vue、React实现excel导出功能(三种实现方式保姆级讲解)
2024年08月04日
vue-office/docx插件实现docx文件预览
2024年08月04日
VUE
java调用js文件的两种方法(支持V8引擎)
2024年08月04日
JavaScript:解决计算精度问题/mathjs/bignumber.js/big.js/decimal.js
2024年08月04日
两周从爬虫小白变大神 _yjs_js_security_passport
2024年08月04日
JS笔记(对象、函数、数组)
2024年08月04日
Markdown.js:强大的纯JavaScript Markdown解析器
2024年08月04日
Vue项目:js模拟点击a标签下载文件并重命名,URL文件地址下载方法、请求接口下载文件方法总结。
2024年08月04日
vue 父组件怎么获取子组件里面的data数据
2024年08月04日
VUE
个人开发实现AI套壳网站快速搭建(Vue+elementUI+SpringBoot)
2024年08月04日
el-table 表格封装并改造实现单元格可编辑
2024年08月04日
none
nodejs环境下创建vue项目、SSH密钥登陆!!!
2024年08月04日
vue+quill+element-ui实现视频、图片上传及缩放保姆级教程,轻松使用富文本
2024年08月04日
【three.js】22. Imported Models导入模型
2024年08月04日