luccastermans / dsm2sql

Convert Dutch Smart Meter to SQL
GNU General Public License v3.0
1 stars 0 forks source link

MySQL error #2

Open luccastermans opened 3 years ago

luccastermans commented 3 years ago

Out of 82641 log-entries in total 128 show

"Error 1064 (You have an error in your SQL syntax check the manual that corresponds to your MariaDB server version for the right syntax to use near ’’ at line 1)

 QRY: INSERT INTO emeter (e_dattijd, e_ver_t1,e_ver_t2,e_ter_t1,e_ter_t2,t, e_ver_mom,e_ter_mom,g_dattijd,g_ver) VALUES (

message. This should not occur.

luccastermans commented 1 year ago

Source file: dm.c

the error message suggests that after line 282 NULL_PTR are encountered with the result than only the qry is specified in lines 276 to 280 is generated. We check the behaviour!

269 static void lines2qry(void)
270 {
271   int i;
272   ASCII dat_in[20];
273   ASCII dat_out[20];
274   ASCII h[7], d[5];
275 
276   strcat(qry, "INSERT INTO emeter "\
277                  "(e_dattijd,"\
278                  " e_ver_t1,e_ver_t2,e_ter_t1,e_ter_t2,t,"\
279                  " e_ver_mom,e_ter_mom,l1,l2,l3,g_dattijd,g_ver) "\
280                  "VALUES (");
281 
282   for ( i = 0;  telegram_ptr[i] != NULL_PTR; i++ )
luccastermans commented 1 year ago

after a reboot of RPI always the first write to mariadb fails!

[2023-01-10 18:15:01] Error 2002 (Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2)) No SQL DB or comport name or could not open comport. process_query() failed [2023-01-10 18:20:11] Error 1064 (You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1) QRY: INSERT INTO emeter (e_dattijd, e_ver_t1,e_ver_t2,e_ter_t1,e_ter_t2,t, e_ver_mom,e_ter_mom,l1,l2,l3,g_dattijd,g_ver) VALUES (

castermn commented 1 year ago

Below illustrates this bug best. Last entry is at 13:05 after power off/on cycle the first entry at 13:45 is wrong.

[2023-03-04 12:50:04] 1 rows affected [2023-03-04 12:55:08] 1 rows affected [2023-03-04 13:00:03] 1 rows affected [2023-03-04 13:05:08] 1 rows affected process_query() failed [2023-03-04 13:45:02] Error 1064 (You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1) QRY: INSERT INTO emeter (e_dattijd, e_ver_t1,e_ver_t2,e_ter_t1,e_ter_t2,t, e_ver_mom,e_ter_mom,l1,l2,l3,g_dattijd,g_ver) VALUES ( [2023-03-04 13:50:08] 1 rows affected [2023-03-04 13:55:12] 1 rows affected [2023-03-04 14:00:07] 1 rows affected [2023-03-04 14:05:11] 1 rows affected [2023-03-04 14:10:06] 1 rows affected [2023-03-04 14:15:10] 1 rows affected [2023-03-04 14:20:06] 1 rows affected [2023-03-04 14:25:11] 1 rows affected