Skip to content
Read data from serial port a write into database, also can save an sql script to run later or csv files.
Python
Branch: master
Clone or download
Latest commit fb3b9bb Jul 17, 2019

README.md

serial2sql

Read data from serial port a write into database, also can save an sql script to run later or csv files.

Installation

Need to install dependencies, use the package manager pip to install dependencies

pip install mysql-connector-python
pip install pySerial

Configure

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)" }
    ]
}

Use

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

Want to know more?

I wrote an article in my blog http://www.gsampallo.com/blog/2019/07/17/serial-a-sql/

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

You can’t perform that action at this time.