Read data from serial port a write into database, also can save an sql script to run later or csv files.
Need to install dependencies, use the package manager pip to install dependencies
pip install mysql-connector-python
pip install pySerial
Edit the config.json according to your installation a needs:
{
"port":"COM3",
"baudrate": 115200,
"credentials" : {
"host":"localhost",
"database":"data",
"user":"root",
"password":"",
"raise_on_warnings": "True"
},
"tableName": "datos1",
"fields": [
{ "name":"indice","type":"INT(10)" },
{ "name":"valor","type":"INT(10)" }
]
}
Once you edit config.json just, on terminal run:
python serial2sql.py
Also you can save an sql file to run later with -o parameter:
python serial2sql.py -o output.sql
Or just save to csv file:
python serial2sql.py -o output.csv
I wrote an article in my blog http://www.gsampallo.com/blog/2019/07/17/serial-a-sql/
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.