Sql Source
This plugin must be used in conjunction with at least a database driver. We are using build tag to determine which driver will be included. This lists all the supported drivers.
This plugin supports drivers by default. User can compile plugin that only support one driver by himself,
for example, if he only wants sqlserver, then he can build with build tag sqlserver
.
Sqlserver build command
The configuration for this source is $ekuiper/etc/sources/sql.yaml
. The format is as below:
User can specify the global sql source settings here. The configuration items specified in default
section will be taken as default settings for the source when running this source.
interval
The target database url
internalSqlQueryCfg
table
: table name to querylimit
: how many items need fetch from the result- : which column for the table act as index to record the offset
indexFieldType
: column type for the indexField, if it is dateTime type, must set this field withDATETIME
dateTimeFormat
: data time format for the index field
table | limit | indexField | indexValue | indexFieldType | dateTimeFormat | sql query statement |
---|---|---|---|---|---|---|
Student | 10 | select * from Student limit 10 | ||||
Student | 10 | stun | 100 | select * from Student where stun > 100 limit 10 | ||
Student | 10 | registerTime | “2022-04-21 10:23:55” | “DATETIME” | “YYYY-MM-dd HH:mm:ss” | select * from Student where registerTime > ‘2022-04-21 10:23:55’ order by registerTime ASC limit 10 |
TemplateSql
: sql statement template- : which column for the table act as index to record the offset
indexValue
: initial index value, if user specify this field, the query will use this initial value as query condition, will update next query when get a greater value.indexFieldType
: column type for the indexField, if it is dateTime type, must set this field withDATETIME
dateTimeFormat
: data time format for the index field
::: v-pre | TemplateSql | indexField | indexValue | indexFieldType | dateTimeFormat | sql query statement | | ————————————————————————————————————————————————- | —————— | ——————————- | ——————— | ——————————- | —————————————————————————————————————————————————- | | select from Student limit 10 | | | | | select from Student limit 10 | | select from Student where stun > {{.stun}} limit 10 | stun | 100 | | | select from Student where stun > 100 limit 10 | | select from Student where registerTime > ‘{{.registerTime}}’ order by registerTime ASC limit 10 | registerTime | “2022-04-21 10:23:55” | “DATETIME” | “YYYY-MM-dd HH:mm:ss” | select from Student where registerTime > ‘2022-04-21 10:23:55’ order by registerTime ASC limit 10 | :::
Note: users only need set internalSqlQueryCfg or templateSqlQueryCfg, if both set, templateSqlQueryCfg will be used
The configuration keys “template_config” will be used.