将DB连接参数传递给Kettle a.k.a PDI表从Excel动态输入步骤 [英] Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel

查看:419
本文介绍了将DB连接参数传递给Kettle a.k.a PDI表从Excel动态输入步骤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个要求,每当我运行我的Kettle工作,数据库连接参数必须从每个运行的excel源动态获取。



说我有一个excel,列名称:HostName,用户名,数据库,密码。



我希望在作业运行时动态地将这些连接参数传递给我的表输入步骤。



这是我想要做的。



解决方案

您可以通过




  • 从源中读取数据库连接参数(例如Excel或在我的示例中为CSV文件)

  • 使用连接设置中的变量将参数存储在变量

  • 中。



继续遵循




  • 为设置变量创建另一个转换(您不能在使用它的相同转换中执行此操作):





设置变量元素中配置变量:






  • 在e读写数据创建一个新连接,并使用 $ {variable_name} 设置连接参数。请注意,您必须将 $ {password} 盲目写入相应的字段。另请注意,这可能是一个安全问题,因为该值可能会在日志文件中显示为纯文本!






  • 在你的工作首先调用变量转换,然后调用功能部分:




I have a requirement such that whenever i run my Kettle job, the database connection parameters must be taken dynamically from an excel source on each run.

Say i have an excel with column names : HostName, Username, Database, Password.

i want to pass these connection parameters to my table input step dynamically whenever the job runs.

This is what i was trying to do.

解决方案

You can achieve this by

  • reading the DB connection parameters from a source (e.g. Excel or in my example a CSV file)
  • storing the parameters in variables
  • using the variables in your connection setting.

Proceed as follows

  • Create another transformation for setting the variables (you cannot do this in the same transformation that uses it):

In the Set Variables element configure the variables:

  • In the element reading/writing your data create a new connection and set the connection parameters using ${variable_name}. Note that you have to blindly write ${password} into the appropriate field. Also note that this may be a security issue because the value may show up as plain text in log files!

  • In your job call the variable transformation first and then the functional part:

这篇关于将DB连接参数传递给Kettle a.k.a PDI表从Excel动态输入步骤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆