I want to read the field names in the mySQL database, then use these names for writing to the database. However, the INSERT-block in labview requires a cluster of data as input and the cluster names cannot be changed during run-time. My question is: Is there any way that labview can read the number of fields and their names and then write data to these fields in the database? Or do I have to hard code the structure of the database before running Labview?
The best I can do at the moment is to compare the names and issue a warning if names in labview doesn't correspond to the field names in the database table. If anyone knows a better way around this, please let me know.
Solved! Go to Solution.
Could you please tell us more about the final use case of your question? It seems that you want to avoid hard-coding in LabVIEW. Why? Because your DB structure is going to change a lot or for other reasons?
The goal of the full project is to monitor multiple physiological parameters and send them to the mySQL database through a stream. The sensor units will stream through bluetooth to labview and labview will then write the data to the server. It is likely that the number of sensors will change during the development of the project and it would be convenient if labview could match inparameters with database fields in run-time instead of reprogramming when we change sensors. For the end product, the database structure will most likely be unchanged and hard coding can be done. I just wondered if there is a way to match sensor data with table fields online.
As far as I understand, I'd probably focus the effort on the DB conception and SQL queries. I'd make a DB with 3 tables (for example SENSOR (Id, Name, other relevant data),DATA (Sensor_Id, Test_Id, Value, Timestamp) and TEST (Id, Measurment_Id, other relevant data). With these tables you'd be able to manage in LabVIEW as many sensors you want without hard coding or change in your program.
Very good tip, thank you. I think we'll use this solution until the final structure of the database is set.