01-04-2012 08:34 AM
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.
01-04-2012 09:11 AM
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.
01-04-2012 09:58 AM
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
01-05-2012 01:59 AM
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?
01-05-2012 02:15 AM
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
01-05-2012 06:45 AM
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