Best way to store attribute data about data sources
-
So I am attempting to use mysql to store the attribute data for each datasource. I have a mysql table created and keyed on the data source xid's and the table columns are represented as the points. The test returns all rows within the table. But how does one query this database dynamically to get only the one row info I am looking for?
-
Hi Phillip,
i'm not sure if I understand your description of the table format. Can you
show create table [your table here];
so that it's more explicit?But how does one query this database dynamically to get only the one row info I am looking for?
It sounds like SQL is going to be the only answer, though perhaps there may be easier table schemas to work with than others.
-
Ok I am just wondering how others do this? Each datasource on our system represent a unique client location. We want to access the attributes stored in the mysql with row based queries on this db indexed on the DS's xid and return one row for each client/datasource xid. The values describe customer details, name, address, geospatial location data that enables the map api to construct and show map markers and info-windows.
I suspect others are using jquery/ajax/php to retrieve the data. Am I missing something on how I can use Mango's SQL implementation to do this?
-
@Phillip-Weeks If you are attempting to retrieve this information on a dashboard then you should use the JSON store.
-
OK lets talk this out. We store all client information in one JSON file? Then load and search the file for the DS xid at runtime to get the associated values? If this is right can you show an example?
-
Have you read the /ui/examples/utilities/json-store page?
Edit: also the /ui/administration/json-store page
-
Awesome thanks guys didn't know these examples existed. I can definitely see the advantage of this format being a great help for sure and much simpler than the php/ajax/sql route no doubt.
-
So I have a more specific question about using the directive
If we have one json file for each DS how do I seed values in the input boxes with stored data using the directive below and the current DSxid as the json file xid?
OK so this is retrieving the data.
Thanks again guys. Great solution!
<ma-json-store xid={{dataSourcesArray[0].xid}} item="ClientInfo" value="myValue"></ma-json-store> -
Everything works great when <ma-json-store> finds the JSON File matching the current DS xid however when the file is not found, it loads xid values from a previous JSON file creation??
These expressions have two different values for the dataSourcesArray[0].xid and dataSourcesArray[0].name?
<ma-json-store xid={{dataSourcesArray[0].xid}} item="ClientInfo" value="myValue"></ma-json-store>
If the JSON file with the xid doesn't exist this directive loads an xid value and name value in the New ClientInfo record as "DS_549018", "DS_549018",
yet {{dataSourcesArray[0].xid}} renders "DS_096207" and {{dataSourcesArray[0].name}} is "DRYAN" which is the correct xid and name for the DS in the designer.watchlist.
-
Problem resolved. So I discovered not all our data sources have identical point names and one of the common points I was using to identify its device name did not exist in certain DS so it reverted to the previous values in the data sources array.
This was nothing to so with the JSON store functionality and its all working as it should now . :) Thanks again guys. -
Certainly! Glad you figured it out!