MySQL Forums
Forum List  »  Connector/Arduino

Just a basic insert
Posted by: Michael Moore
Date: April 30, 2014 03:03PM

I kinda feel like a fool, I just want to do an Insert every minute to a MySQL database. Up until now I've had a laptop connected to the Arduino running a PowerShell script that did the task of reading the "blinks" counted and written to the serial connection and then posting them along with the time to the MySQL database. I'd like to remove the laptop. I keep thinking I've halfway figured out what I'm doing and then I end up feeling lost again.

http://pastebin.com/mQN4UcA1

This is what I've got so far, it's my old code with the Ethernet adapter and MySQL Connector code added. You can see it used to (and technically still does) write to the Serial connection, just the blink count. Now I want it to write straight to the database. There are a few things I'm not sure about and that concern me.

One is the whole reading every column/row thing. Does it actually need to do that? It seems like that would take forever. I'm just writing to the database and it's not the end of the world if I loose data. What would be the disadvantage of skipping that?

Secondly, how would I build the following query, I know it's somewhere in these examples, and I'll probably figure it out before I get a response, but sometimes I don't seem to be able to figure something out before I ask, then it just becomes obvious :)

INSERT INTO `test_arduino`.`homedb_power` (`DateTime`, `WattHour`) VALUES (Date_Format(NOW(),'%Y-%m-%d %H:%i:00'), 10);



Thanks for any assistance.

Options: ReplyQuote


Subject
Views
Written By
Posted
Just a basic insert
1910
April 30, 2014 03:03PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.