LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Insert 2D array into database

I am trying to insert a 2D array of data into a MySQL database after a trial is run. I have read that LabVIEW's Database Insert VI does not support any more than the insertion of 1D arrays at a time. While it might be possible for me to insert the values all individually using a for loop to format the values before entering them, this is far from ideal since there will be 600+ rows of data coming from each trial. I would rather get on to the next run rather than wait for a minute and a half while the Insert VI does its job. Any ideas on how to quickly insert large 2D arrays into the database?

I would post an example of my code, but it's such a mess right now I am embarrassed to show it Smiley Very Happy. Thanks!
0 Kudos
Message 1 of 7
(8,169 Views)
MySQL support an INSERT statement that inserts multiple rows, as noted here. However, since the Database Insert VI doesn't support this you will need to code this up yourself. I'm guessing you're using the Database Connectivity Toolkit. I don't have the Database Connectivity Toolkit, but ff there's a VI in there that will let you create your own INSERT statement then you could do it. There may be one that allows you to specify a command. In that case, the command would be the INSERT statement. I know you can create your own command with LabSQL.
0 Kudos
Message 2 of 7
(8,155 Views)
What form do you want the 2D array to be in, a number of separate records, or a single BLOB containing the entire array in binary?

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 3 of 7
(8,140 Views)
A follow up on my earlier post...  Check out this thread for a discussion of the issues related to connecting to a database - also a set of good ADO-based drivers.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 4 of 7
(8,138 Views)
Thanks Mike, those VIs look pretty good. I will give them a shot. To answer your previous question, I want each row of the 2D array to be entered as a separate entry into the table. Any tips on how to do this with your VIs? Thanks.
0 Kudos
Message 5 of 7
(8,078 Views)
Just to clarify, I know I can format the values into a text file then dump that into the database, but I am trying to simplify the process so that I won't have to backtrack and micromanage my code so much if I ever have to modify the database. I was doing this before, and it worked great, but the setup process of making sure the text formatted itself correctly was so cumbersome that I am looking for other methods.
0 Kudos
Message 6 of 7
(8,076 Views)
The easiest thing to do would be to index through the array inserting each row as a separate BLOB in binary form. This is easy to do, takes up the least amount of storage space, preserves all the data's numeric precision and is easy to read from other applications or programming languages...

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 7 of 7
(8,015 Views)