- printf("insert into %s values (\"%s\",%u);\n", table, tstr, val);
- return 0;
+ mysql_init(&mysql);
+ if(!mysql_real_connect(&mysql, NULL, "pulsecounter",
+ "xxxxxxxxxxxxx", "watermeter", 0, NULL, 0)) {
+ fprintf(stderr, "mysql connect error: %s\n",
+ mysql_error(&mysql));
+ return 1;
+ }
+ snprintf(statement, sizeof(statement),
+ "insert into %s values (\"%s\",%u);\n",
+ table, tstr, val);
+ rc = mysql_query(&mysql, statement);
+ if (rc)
+ fprintf(stderr, "mysql insert \"%s\" error: %s\n",
+ statement, mysql_error(&mysql));
+ mysql_close(&mysql);
+ return rc;