Mango scada database access
-
Hi, I was wondering how to put data from mango database into a datapoint. Specifically, I want to have a datapoint showing the number of N values in SILENCED field in USEREVENTS table. I tried using Meta Datapoint, but it didn't recognize SQL statements for Rhino. I've also found SQL datasources and datapoints, but from user help it seemed to me that those datapoints are for external, nonmango databases. Any suggestions on what should I do to accomplish this?
Also, I'd like to display a number of (for example ten) latest Mango alarms in DGLux, does anyone know the path to the table containing that info?
Thanks, Stefan.
-
Hi Stefan,
You can still use the SQL data source to investigate Mango's own database. I would be wary of doing much if any alteration of the database from the datasource (just cautious, i'm sure there are reasons to). If you're running on H2, the connection string is provided in the help for the SQL datasource (whose first sentence on connectivity is "Any database supported by JDBC can be accessed." I might add :), but I believe it's org.h2.Driver, and the connection string will be (if you used the default) /path/to/Mango/databases/mah2
You can find your username and password in your env.properties file, but they are blank by default. Similarly, you could connect the SQL datasource to your Mango's MySQL database if that is where your database is.
"Alarms" are in the events table. So something like SELECT * FROM events WHERE alarmLevel>0 ORDER BY activeTs DESC LIMIT 10;
-
Thanks for your answer phil, but I think SQL datasource is not gonna solve my problem after all. I think only Meta datasource can help, since I need fetch the USEREVENTS table, and go through the rows counting how many N values are in the SILENCED field. Is it possible to connect to the database in Meta datapoint/global script, and if it is, which functions are used for connecting and submitting a query?
-
Hi Stefan,
You can not use SQL queries in Meta Data Points, Scripting Data Sources or Global Scripts.
If you are using DGLux I think this video will help you:
You can also create a SQL data point like Phillip described.
-
I should add that I would recommend you look at the AngularJS frame work that uses the Mango API. I'm not exactly sure what you want to do there but it might be possible through the API.
https://help.infiniteautomation.com/support/solutions/folders/14000104696 -
Well, Joe, I'm making a dashboard in DGLux, and one of the things I want to display there is the number of nonsilenced nonacknowledged alarms from mango, so the user could see that on the dashboard, and go to mango to acknowledge or silence them.
Thx for the video and link.