5 #include <mysql/mysql.h>
9 int dbstore(uint8_t which, uint32_t val)
18 char *table = (which == 1) ? "coldcnt" : "hotcnt";
22 (void)gmtime_r(&t, &tm);
23 (void)strftime(tstr, sizeof(tstr), "%Y-%m-%d %H:%M:%S", &tm);
25 if(!mysql_real_connect(&mysql, NULL, "pulsecounter",
26 "xxxxxxxxxxxxx", "watermeter", 0, NULL, 0)) {
27 fprintf(stderr, "mysql connect error: %s\n",
31 snprintf(statement, sizeof(statement),
32 "insert into %s values (\"%s\",%u);\n",
34 rc = mysql_query(&mysql, statement);
36 fprintf(stderr, "mysql insert \"%s\" error: %s\n",
37 statement, mysql_error(&mysql));