Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char buf[LEN];
- time_t curtime;
- struct tm *loc_time;
- curtime = time (NULL);
- loc_time = localtime (&curtime);
- strftime (buf, LEN, "%Y-%m-%d" " " "%X", loc_time);
- fputs (buf, stdout);
- MYSQL *con = mysql_init(NULL);
- if (con == NULL)
- {
- fprintf(stderr, "mysql_init() failedn");
- exit(1);
- }
- if (mysql_real_connect(con, "localhost", "user", "pass", "TempDB", 0, NULL, 0) == NULL)
- {
- finish_with_error(con);
- }
- if (mysql_query(con, "CREATE TABLE IF NOT EXISTS TempMeas(MeasTime DATETIME, Temp DOUBLE)"))
- {
- finish_with_error(con);
- }
- if (mysql_query(con, "INSERT INTO TempMeas(MeasTime, Temp) VALUES('%d', '%d')", buf, j))
- {
- finish_with_error(con);
- }
- mysql_close(con);
- exit(0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement