edit MySQL plugin - save all given information from data[ ] into MySQL database

This commit is contained in:
Schrolli 2015-06-30 12:26:27 +02:00
parent 64768e544e
commit d28dfa951b
2 changed files with 5 additions and 8 deletions

View file

@ -15,7 +15,7 @@ unless you are developer you can use the develop-Branch - may be unstable!
##### Implemented features:
- FMS, ZVEI and POCSAG512/1200/2400 decoding and displaying
- Plugin support for easy functional extension
- Filtering double alarms with adjustable time
- Filtering double alarms with adjustable time and check width
- Filtering allowed, denied and range of POCSAG RIC´s
- Filtering data for each typ/plugin combination with RegEX
- All configurations in a seperate config file
@ -118,6 +118,7 @@ In case of an error during the installation, check the logfile in `~/boswatch/in
Caution, script don't install a webserver with PHP and MySQL.
So you have to make up manually if you want to use MySQL support.
Database Structure `boswatch.sql` in the MySQL Plugin Folder
If you want to use BOSWatch as a daemon, you have to set your
configuration in `service/boswatch.sh` and copy it to `/etc/init.d`.

View file

@ -92,17 +92,13 @@ def run(typ,freq,data):
logging.debug("Insert %s", typ)
if typ == "FMS":
#data = {"fms":fms_id[0:8], "status":fms_status, "direction":fms_direction, "tsi":fms_tsi}
cursor.execute("INSERT INTO "+globals.config.get("MySQL","tableFMS")+" (time,fms,status,direction,tsi) VALUES (NOW(),%s,%s,%s,%s)",(data["fms"],data["status"],data["direction"],data["tsi"]))
cursor.execute("INSERT INTO "+globals.config.get("MySQL","tableFMS")+" (time,fms,status,direction,directionText,tsi,description) VALUES (NOW(),%s,%s,%s,%s,%s,%s)",(data["fms"],data["status"],data["direction"],data["directionText"],data["tsi"],data["description"]))
elif typ == "ZVEI":
#data = {"zvei":zvei_id}
#Don't use %s here (bug in mysql-lib with one parameter)
cursor.execute("INSERT INTO "+globals.config.get("MySQL","tableZVEI")+" (time,zvei) VALUES (NOW(),"+(data["zvei"])+")")
cursor.execute("INSERT INTO "+globals.config.get("MySQL","tableZVEI")+" (time,zvei,description) VALUES (NOW(),%s,%s)",(data["zvei"],data["description"]))
elif typ == "POC":
#data = {"ric":poc_id, "function":poc_sub, "msg":poc_text}
cursor.execute("INSERT INTO "+globals.config.get("MySQL","tablePOC")+" (time,ric,funktion,text) VALUES (NOW(),%s,%s,%s)",(data["ric"],data["function"],data["msg"]))
cursor.execute("INSERT INTO "+globals.config.get("MySQL","tablePOC")+" (time,ric,funktion,funktionChar,msg,bitrate,description) VALUES (NOW(),%s,%s,%s,%s,%s,%s)",(data["ric"],data["function"],data["functionChar"],data["msg"],data["bitrate"],data["description"]))
else:
logging.warning("Invalid Typ: %s", typ)