Skip to content

Commit

Permalink
fix(docs): add description for using sql source/sink (#1258)
Browse files Browse the repository at this point in the history
* fix(docs): add description for using sql source/sink

Signed-off-by: Jianxiang Ran <rxan_embedded@163.com>
  • Loading branch information
superrxan authored Apr 28, 2022
1 parent 220eb28 commit c6c2657
Show file tree
Hide file tree
Showing 15 changed files with 418 additions and 60 deletions.
2 changes: 1 addition & 1 deletion docs/en_US/rules/sinks/builtin/rest.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The action is used for publish output message into a RESTful API.
| Property name | Optional | Description |
|--------------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| method | true | The HTTP method for the RESTful API. It is a case insensitive string whose value is among "get", "post", "put", "patch", "delete" and "head". The default value is "get". |
| url | false | The RESTful API endpoint, such as `https://www.example.com/api/dummy` |
| url | false | The RESTful API endpoint, such as `https://www.example.com/api/dummy` |
| bodyType | true | The type of the body. Currently, these types are supported: "none", "json", "text", "html", "xml", "javascript" and "form". For "get" and "head", no body is required so the default value is "none". For other http methods, the default value is "json" For "html", "xml" and "javascript", the dataTemplate must be carefully set up to make sure the format is correct. |
| timeout | true | The timeout (milliseconds) for a HTTP request, defaults to 5000 ms |
| headers | true | The additional headers to be set for the HTTP request. |
Expand Down
6 changes: 3 additions & 3 deletions docs/en_US/rules/sinks/plugin/file.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ Restart the eKuiper server to activate the plugin.

## Properties

| Property name | Optional | Description |
| ------------- | -------- | ------------------------------------------------------------ |
| path | false | The file path for saving the result, such as `/tmp/result.txt` |
| Property name | Optional | Description |
|---------------|----------|-------------------------------------------------------------------------------------------------------------------------------------------------|
| path | false | The file path for saving the result, such as `/tmp/result.txt` |
| interval | true | The time interval (ms) for writing the analysis result. The default value is 1000, which means write the analysis result with every one second. |

## Sample usage
Expand Down
10 changes: 5 additions & 5 deletions docs/en_US/rules/sinks/plugin/image.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ Restart the eKuiper server to activate the plugin.

## Attribute

| Attribute name | Optional | Description |
| -------------- | -------- | ------------------------------------------------------------ |
| Attribute name | Optional | Description |
|----------------|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| path | False | The name of the folder where the pictures are saved, such as `./tmp`. Note: For multiple rules, their paths cannot be repeated, otherwise they will be deleted from each other. |
| format | False | File format, support jpeg and png. |
| maxAge | True | Maximum file storage time (hours). The default value is 72, which means that the picture can be stored for up to 3 days. |
| maxCount | True | The maximum number of stored pictures. The default value is 1000. The earlier pictures will be deleted. The relationship with `maxAge` is OR. |
| format | False | File format, support jpeg and png. |
| maxAge | True | Maximum file storage time (hours). The default value is 72, which means that the picture can be stored for up to 3 days. |
| maxCount | True | The maximum number of stored pictures. The default value is 1000. The earlier pictures will be deleted. The relationship with `maxAge` is OR. |

## Usage example

Expand Down
18 changes: 9 additions & 9 deletions docs/en_US/rules/sinks/plugin/influx.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ Restart the eKuiper server to activate the plugin.

## Properties

| Property name | Optional | Description |
| ------------- | -------- | ------------------------------------------------------------ |
| addr | true | The addr of the InfluxDB |
| Property name | Optional | Description |
|---------------|----------|---------------------------------------------------|
| addr | true | The addr of the InfluxDB |
| measurement | true | The measurement of the InfluxDb (like table name) |
| username | false | The InfluxDB login username |
| password | false | The InfluxDB login password |
| databasename | true | The database of the InfluxDB |
| tagkey | true | The tag key of the InfluxDB |
| tagvalue | true | The tag value of the InfluxDB |
| fields | true | The column of the InfluxDB,split with "," |
| username | false | The InfluxDB login username |
| password | false | The InfluxDB login password |
| databasename | true | The database of the InfluxDB |
| tagkey | true | The tag key of the InfluxDB |
| tagvalue | true | The tag value of the InfluxDB |
| fields | true | The column of the InfluxDB,split with "," |
## Sample usage

Below is a sample for selecting temperature great than 50 degree, and some profiles only for your reference.
Expand Down
16 changes: 8 additions & 8 deletions docs/en_US/rules/sinks/plugin/redis.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ Restart the eKuiper server to activate the plugin.

## Properties

| Property name | Optional | Description |
| ------------- | -------- | ------------------------------------------------------------ |
| addr | false | The addr of the Redis,example: 10.122.48.17:6379 |
| password | true | The Redis login password|
| db | false | The database of the Redis,example: 0 |
| key | false | Select one of the Key, Key and field of Redis data and give priority to field |
| field | true | This field must exist and be of type string. Otherwise, use the field character as the key. Note: Do not use a data template to configure this value |
| Property name | Optional | Description |
|---------------|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| addr | false | The addr of the Redis,example: 10.122.48.17:6379 |
| password | true | The Redis login password |
| db | false | The database of the Redis,example: 0 |
| key | false | Select one of the Key, Key and field of Redis data and give priority to field |
| field | true | This field must exist and be of type string. Otherwise, use the field character as the key. Note: Do not use a data template to configure this value |
| dataType | false | The default Redis data type is string. Note that the original key must be deleted after the Redis data type is changed. Otherwise, the modification is invalid. now only support "list" and "string" |
| expiration | false | Timeout duration of Redis data. This parameter is valid only for string data in seconds. The default value is -1 |
| expiration | false | Timeout duration of Redis data. This parameter is valid only for string data in seconds. The default value is -1 |
## Sample usage

Below is a sample for selecting temperature great than 50 degree, and some profiles only for your reference.
Expand Down
57 changes: 57 additions & 0 deletions docs/en_US/rules/sinks/plugin/sql.md
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"]
}
}
]
}
```

8 changes: 4 additions & 4 deletions docs/en_US/rules/sinks/plugin/zmq.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ Restart the eKuiper server to activate the plugin.

## Properties

| Property name | Optional | Description |
| ------------- | -------- | ------------------------------------------------------------ |
| server | false | The url of the Zero Mq server |
| topic | true | The topic to publish to |
| Property name | Optional | Description |
|---------------|----------|-------------------------------|
| server | false | The url of the Zero Mq server |
| topic | true | The topic to publish to |

## Sample usage

Expand Down
Loading

0 comments on commit c6c2657

Please sign in to comment.