LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to log mutiple records to database

Hello,

 

We have to read data from a sensor (producing a set of 10 output values with a frequency of 200Hz) and log those data to a database. We have the database toolkit.

We succeed in acquiring data and writing them to a database (using the DB Tools Insert Data VI) set by set (=one record each time). This means 200 write actions per second.

 

We think that writing the data batchwise (block of 200 records) is much better, but have no idea how to do.

 

Anyone having hints to do so?

 

John.

 

P.S.: We use Microsoft Access 2010 database.

 

0 Kudos
Message 1 of 6
(3,931 Views)

You can use a Queue to build up batches of the desired size, and then write to the file. You could do this action in a separate loop, enqueue the data in your existing loop, and dequeue the data when the Queue size = X in a new loop.

Richard






0 Kudos
Message 2 of 6
(3,925 Views)

With a SQL insert command you can easily add several lines at once, just write a factor of insert-column parameters in the query.

You'll probably have to manually build the sql string and then perform an Execute Query (assuming you have DB toolkit).

 

There are some limits to how long a query can be, so if it's alot of parameters you might have to write less than 200.

It shouldn't be too hard.

 

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 3 of 6
(3,921 Views)

Using a queue is a good idea, but in that way still I have to write 200 records per second to the database. How to write 200 records in one write action?

0 Kudos
Message 4 of 6
(3,904 Views)

Yameada,

 

I like your idea to write several lines at once! But my brains need more explanation of your idea. Can you give me that? May be a small VI? (Yes, we have the DB toolkit)

 

John

0 Kudos
Message 5 of 6
(3,901 Views)

http://en.wikipedia.org/wiki/Insert_(SQL)

 

VI is Open Database, Execute query, Close database. 😉

 

A query example is:

INSERT INTO Measurements (time,data) VALUES

('11:48:32,000',0.1),

('11:48:32,320',0.3),

('11:48:32,640',0.5),

('11:48:32,960',0.7),

('11:48:33,220',0.8);

 

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
Message 6 of 6
(3,894 Views)