LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

can I insert a column of array into mysql?

Solved!
Go to solution

hello

I have a long coulmn of array of numbers. I use labsql to connect with mysql.

when I have a number, I change my number to string and then concatenate it with insert commands to insert my number to mysql table.

now, I want insert a long column of numbers to mysql but it is difficult. because for is need to does it like before.

can I insert this array as a batch and without use a "for" and as fast as possible?

 

Best Regards

0 Kudos
Message 1 of 14
(7,461 Views)

@behzad1 wrote:

hello

I have a long coulmn of array of numbers. I use labsql to connect with mysql.

when I have a number, I change my number to string and then concatenate it with insert commands to insert my number to mysql table.

now, I want insert a long column of numbers to mysql but it is difficult. because for is need to does it like before.

can I insert this array as a batch and without use a "for" and as fast as possible?

 

Best Regards


Yes, you can save arrays as well.

 

But first- do you have to save an array such that you're able to work with any of its element in mysql?  If you don't need to do that (meaning, if you can work with reading back the whole array and then do work within LabVIEW after that), then one idea is to base64 encode your array, then send as string to save to mysql. When reading it back you'll have to reverse that process.

 

Make sure that your mysql table is set for correct data-type (such as BINARY, VARBINARY, BLOB, TINYBLOB. BINARY being faster) to handle the data.  That should be quite fast and you don't have to go through a for-loop of multiple sql calls.

 

If you need to work with any of the elements of your array while it's stored in mysql, that's more involved and it would require you to first restructure your table differently...

 

-BTC

--------------------------------------------------------

New Controls & Indicators made using vector graphics & animations? Click below for Pebbles UI


Message 2 of 14
(7,432 Views)

Thank you BTC_Admin

 

yes, I need to use any of its element seperatly and I use some of my array to diffrent form, for example column 2 .

 now, how can I do it?

 

Can I change my array to this form in labview without "for"  as a new way to inser in a table?

 

1 9 8

3 5 6

9 8 4

 

 to:

 

(1,9,8)(3,5,6)(9,8,4)

 

because, (1,9,8)(3,5,6)(9,8,4) can insert easily.

 

I can use "," between my numbers by "Array To Spreadsheet String Function" and change it to this form:

 

1,9,8

3,5,6

9,8,4

 

but I can't add parenthesis without "for" and reshape it in a row.

 

Best Regards

0 Kudos
Message 3 of 14
(7,401 Views)

 

 

 

(num1,num2)

(num3,num4)

(num5,num6)

(num7,num8)

 

from array num:

 

[num1 num2

num3 num4

num5 num6

num7 num8]

 

Best Regards

 

0 Kudos
Message 5 of 14
(7,379 Views)
I don't see the problem with creating the INSERT. What have you tried? How big is the array? What have you tried?
0 Kudos
Message 6 of 14
(7,376 Views)

@behzad1 wrote:

I can use "," between my numbers by "Array To Spreadsheet String Function" and change it to this form:

 1,9,8

3,5,6

9,8,4

 


After that, replace all \r\n with )( and add ( in the beginning and ) at the end.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 14
(7,369 Views)

 

I'm not mean there are problem to creat INSERT. please see the attached picture. I concatenate two number like picture to insert in mysql. I add two number from an array and inset them. now, suppose, my numbers row is 2000 (2000*6). then, we need a for to repeat this command like picture or I should change my array number to this format:

(num1,num2)

(num3,num4)

(num5,num6)

(num7,num8)

 

and then, I use one insert command to insert result of "for" as your link suggestion.

can I change to this format by a block of labview? because it seems mysql command can't insert an array

 

 

Best Regards

0 Kudos
Message 8 of 14
(7,363 Views)

Yamaeda

 

Which block do you mean?

I used "Search and Replace Pattern VI"

but it use a "for"

 

 

Best Regards

0 Kudos
Message 9 of 14
(7,362 Views)

@behzad1 wrote:

Yamaeda

 

Which block do you mean?

I used "Search and Replace Pattern VI"

but it use a "for"

 

 

Best Regards


Yes, a single Search and Replace with Replace all=True should take care of the )( part, then a concatenate string to add the parenthesis in the beginning and end.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 10 of 14
(7,353 Views)