User Tools

Site Tools


raspberrypi:mysql

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
raspberrypi:mysql [2017/03/11 17:12] – aistisraspberrypi:mysql [2017/03/13 10:44] (current) – aistis
Line 1: Line 1:
 +reikia instaliuoti mysql biblioteka kad galima butu programuoti mysql per c/c++ 
 <code> <code>
 sudo apt-get update sudo apt-get update
Line 10: Line 11:
   sudo apt-get install mysql-client   sudo apt-get install mysql-client
  
 +
 +<code c>
 +#include <stdio.h>
 +#include <stdlib.h>
 +#include <signal.h>
 + 
 +#include <mysql/mysql.h>
 + 
 +#include <pigpio.h>
 + 
 +/* 
 +gcc -Wall -pthread -o test_mysql test_mysql.c -lpigpio -O3 `mysql_config --cflags` `mysql_config --libs`
 +sudo ./test_mysql
 +*/
 +
 + 
 +int main(int argc, char *argv[])
 +{
 +  if (gpioInitialise() < 0) return -1;
 +
 +  MYSQL *con = mysql_init(NULL);
 +
 +  if (con == NULL) 
 +  {
 +      fprintf(stderr, "%s\n", mysql_error(con));
 +      exit(1);
 +  }
 +
 +  if (mysql_real_connect(con, "xxx.lt", "algo_xxxx", "xxxxx", 
 +          "algo_aistis", 0, NULL, 0) == NULL) 
 +  {
 +      fprintf(stderr, "%s\n", mysql_error(con));
 +      mysql_close(con);
 +      exit(1);
 +  }  
 +
 +  if (mysql_query(con, "insert into temperature (ts, value, location) values (LOCALTIMESTAMP(), 10, 'HOME_NORTH');")) 
 +  {
 +      fprintf(stderr, "%s\n", mysql_error(con));
 +      mysql_close(con);
 +      exit(1);
 +  }
 +
 +  mysql_close(con);
 +
 +  return 0;   
 +}
 +</code>
raspberrypi/mysql.1489245140.txt.gz · Last modified: by aistis