This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Read/write mysql database
#24
Hi all,

I've got my connection working and am successfully writing data to my database on the server. However, I cannot write to a MySQL field of the type "datetime". It should have the format "YYYY-MM-DD HH:MM:SS".

I am doing this and getting an error:
Code:
-- create timestamp
curdatetime = os.date("%Y-%m-%d %H:%M:%S")

-- write to database
cursor = dbcon:execute('INSERT INTO sensor_data (LAST_UPDATE) VALUES (STR_TO_DATE(' .. curdatetime .. ',"%Y-%m-%d %h:%i:%s"))')

Sorry for asking MySQL related questions here which actually have nothing to do with the LogicMacine itself, but I hope some expert here can tell me where the error in the above code is.

Many thanks and best regards
Reply


Messages In This Thread
Read/write mysql database - by gjniewenhuijse - 14.01.2016, 09:49
RE: Read/write mysql database - by admin - 14.01.2016, 10:03
RE: Read/write mysql database - by RSV4 - 20.03.2016, 10:33
RE: Read/write mysql database - by admin - 21.03.2016, 06:59
RE: Read/write mysql database - by RSV4 - 21.03.2016, 09:59
RE: Read/write mysql database - by admin - 11.10.2016, 10:24
RE: Read/write mysql database - by g2g2g2 - 02.11.2016, 13:40
RE: Read/write mysql database - by g2g2g2 - 08.11.2016, 08:23
RE: Read/write mysql database - by admin - 08.11.2016, 08:26
RE: Read/write mysql database - by RSV4 - 06.12.2016, 23:08
RE: Read/write mysql database - by admin - 07.12.2016, 07:12
RE: Read/write mysql database - by RSV4 - 07.12.2016, 08:45
RE: Read/write mysql database - by admin - 07.12.2016, 09:09
RE: Read/write mysql database - by RSV4 - 07.12.2016, 09:27
RE: Read/write mysql database - by RSV4 - 18.12.2016, 00:05
RE: Read/write mysql database - by RSV4 - 18.12.2016, 07:58
RE: Read/write mysql database - by RSV4 - 18.12.2016, 10:28
RE: Read/write mysql database - by RSV4 - 11.01.2017, 23:19
RE: Read/write mysql database - by admin - 12.01.2017, 09:48
RE: Read/write mysql database - by RSV4 - 12.01.2017, 18:50
RE: Read/write mysql database - by FatMax - 17.02.2017, 12:45
RE: Read/write mysql database - by yeuwoo - 14.03.2017, 03:16
RE: Read/write mysql database - by admin - 14.03.2017, 06:53
RE: Read/write mysql database - by Thomas - 14.03.2017, 14:34
RE: Read/write mysql database - by admin - 05.09.2017, 13:50
RE: Read/write mysql database - by admin - 07.09.2017, 14:47
RE: Read/write mysql database - by pentadom - 18.11.2019, 16:54
RE: Read/write mysql database - by Daniel - 19.11.2019, 08:28
RE: Read/write mysql database - by pentadom - 19.11.2019, 09:37
RE: Read/write mysql database - by admin - 19.11.2019, 09:49
RE: Read/write mysql database - by pentadom - 19.11.2019, 10:22
RE: Read/write mysql database - by admin - 19.11.2019, 12:06
RE: Read/write mysql database - by pentadom - 19.11.2019, 12:23
RE: Read/write mysql database - by admin - 19.11.2019, 14:07
RE: Read/write mysql database - by pentadom - 19.11.2019, 19:12
RE: Read/write mysql database - by admin - 20.11.2019, 07:47
RE: Read/write mysql database - by pentadom - 17.05.2020, 08:18
RE: Read/write mysql database - by pentadom - 17.05.2020, 14:57
RE: Read/write mysql database - by Daniel - 18.05.2020, 07:38
RE: Read/write mysql database - by pentadom - 18.05.2020, 07:55
RE: Read/write mysql database - by admin - 18.05.2020, 07:50
RE: Read/write mysql database - by admin - 18.05.2020, 07:58
RE: Read/write mysql database - by pentadom - 18.05.2020, 08:01
RE: Read/write mysql database - by Daniel - 18.05.2020, 08:06
RE: Read/write mysql database - by pentadom - 18.05.2020, 08:08
RE: Read/write mysql database - by pentadom - 19.05.2020, 16:08
RE: Read/write mysql database - by admin - 20.05.2020, 07:38
RE: Read/write mysql database - by pentadom - 20.05.2020, 16:27

Forum Jump: