SQLite Writer
SQLite Writer plugin implements the functionality of writing data to SQLite database.
Example
Assume the table to be written is as follows:
create table addax_tbl ( col1 varchar(20) , col2 int(4), col3 datetime, col4 boolean, col5 binary );
Here we use data generated from memory to SQLite.
json
{
"job": {
"setting": {
"speed": {
"channel": 1,
"bytes": -1
}
},
"content": {
"reader": {
"name": "streamreader",
"parameter": {
"column": [
{
"value": "Addax",
"type": "string"
},
{
"value": 19880808,
"type": "long"
},
{
"value": "1988-08-08 08:08:08",
"type": "date"
},
{
"value": true,
"type": "bool"
},
{
"value": "test",
"type": "bytes"
}
],
"sliceRecordCount": 1000
}
},
"writer": {
"name": "sqlitewriter",
"parameter": {
"writeMode": "insert",
"column": [
"*"
],
"preSql": [
"delete from @table"
],
"connection": {
"jdbcUrl": "jdbc:sqlite://tmp/writer.sqlite3",
"table": [
"addax_tbl"
]
}
}
}
}
}
}Save the above configuration file as job/stream2sqlite.json
Execute Collection Command
Execute the following command for data collection
bash
bin/addax.sh job/stream2sqlite.jsonParameters
This plugin is based on RDBMS Writer, so you can refer to all configuration items of RDBMS Writer. Since SQLite connection does not require username and password, the username and password that other database writer plugins need to configure are not needed here.
writeMode
insertmeans usinginsert intoreplacemeans usingreplace intomethodupdatemeans usingON DUPLICATE KEY UPDATEstatement
Type Conversion
| Addax Internal Type | SQLite Data Type |
|---|---|
| Long | integer |
| Double | real |
| String | varchar |
| Date | datetime |
| Boolean | bool |
| Bytes | blob, binary |