SQL Loader
DataLoader 模块配置为使用此加载器功能。SQL 加载器用于从 SQL 数据库获取数据并将其存储在 DataFrame 中,并返回更新后的 ControlMessage 对象,其有效负载为 MessageMeta。
{
"loaders": [
{
"id": "SQLLoader"
}
]
}
注意 : 加载器可以通过 ControlMessage 在运行时从 load
任务接收配置。
可以在加载任务级别为此特定加载器配置的参数
参数 |
类型 |
描述 |
示例值 |
默认值 |
---|---|---|---|---|
strategy |
string | 组合查询的策略 | "aggregate" |
aggregate |
loader_id |
string | 加载器的唯一标识符 | "file_to_df" |
[必需] |
sql_config |
dictionary | 包含要运行的 SQL 查询的字典 | "file_to_df" |
请参考下文 |
sql_config
参数 |
类型 |
描述 |
示例值 |
默认值 |
---|---|---|---|---|
queries |
list | 构成查询定义的字典列表 | "[query_dict_1, ..., query_dict_n]" |
请参考下文 |
queries
参数 |
类型 |
描述 |
示例值 |
默认值 |
---|---|---|---|---|
connection_string |
string | 组合查询的策略 | "postgresql://postgres:postgres@localhost:5432/postgres" |
[必需] |
query |
string | 要执行的 SQL 查询 | "SELECT * FROM test_table WHERE id IN (?, ?, ?)" |
[必需] |
params |
dictionary | 命名或位置参数值 | "[foo, bar, baz]" |
- |
以下 JSON 配置指定了如何在运行时通过控制消息任务将其他配置传递给加载器。
{
"type": "load",
"properties": {
"loader_id": "SQLLoader",
"strategy": "aggregate",
"sql_config": {
"queries": [
{
"connection_string": "postgresql://postgres:postgres@localhost:5431/postgres",
"query": "SELECT * FROM test_table WHERE id IN (?, ?, ?)",
"params": [
"foo",
"bar",
"baz"
]
}
]
}
}
}