-
Notifications
You must be signed in to change notification settings - Fork 423
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(docs): add description for using sql source/sink (#1258)
* fix(docs): add description for using sql source/sink Signed-off-by: Jianxiang Ran <rxan_embedded@163.com>
- Loading branch information
Showing
15 changed files
with
418 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Sql Sink | ||
|
||
The sink will write the result to the database. | ||
|
||
## Compile & deploy plugin | ||
|
||
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 [repository](https://github.com/lf-edge/ekuiper/tree/master/extensions/sqldatabase/driver) lists all the supported drivers. | ||
|
||
This plugin supports `sqlserver\postgres\mysql\sqlite3\oracle` drivers by default. User can compile plugin that only support one driver by himself, | ||
for example, if he only wants mysql, then he can build with build tag `mysql`. | ||
|
||
### Default build command | ||
```shell | ||
# cd $eKuiper_src | ||
# go build -trimpath -modfile extensions.mod --buildmode=plugin -o plugins/sinks/Sql.so extensions/sinks/sql/sql.go | ||
# cp plugins/sinks/Sql.so $eKuiper_install/plugins/sinks | ||
``` | ||
|
||
### MySql build command | ||
```shell | ||
# cd $eKuiper_src | ||
# go build -trimpath -modfile extensions.mod --buildmode=plugin -tags mysql -o plugins/sinks/Sql.so extensions/sinks/sql/sql.go | ||
# cp plugins/sinks/Sql.so $eKuiper_install/plugins/sinks | ||
``` | ||
|
||
|
||
## Properties | ||
|
||
| Property name | Optional | Description | | ||
|---------------|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| url | false | The url of the target database | | ||
| table | false | The table name of the result | | ||
| fields | false | The fields to be inserted to. The result map and the database should both have these fields. If not specified, all fields in the result map will be inserted. | | ||
|
||
## Sample usage | ||
|
||
Below is a sample for using sql to get the target data and set to mysql database | ||
|
||
```json | ||
{ | ||
"id": "rule", | ||
"sql": "SELECT stuno as id, stuName as name, format_time(entry_data,\"YYYY-MM-dd HH:mm:ss\") as registerTime FROM SqlServerStream", | ||
"actions": [ | ||
{ | ||
"log": { | ||
}, | ||
"sql": { | ||
"url": "mysql://user:test@140.210.204.147/user?parseTime=true", | ||
"table": "test", | ||
"fields": ["id","name","registerTime"] | ||
} | ||
} | ||
] | ||
} | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.