raspberrypi:mysql
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| raspberrypi:mysql [2017/03/11 14:26] – created aistis | raspberrypi:mysql [2017/03/13 10:44] (current) – aistis | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | reikia instaliuoti mysql biblioteka kad galima butu programuoti mysql per c/c++ | ||
| < | < | ||
| sudo apt-get update | sudo apt-get update | ||
| Line 6: | Line 7: | ||
| http:// | http:// | ||
| + | |||
| + | tiesiog instaliuoti mysql klienta kuris leidzia jungtis prie kitos bazes | ||
| + | sudo apt-get install mysql-client | ||
| + | |||
| + | |||
| + | <code c> | ||
| + | #include < | ||
| + | #include < | ||
| + | #include < | ||
| + | |||
| + | #include < | ||
| + | |||
| + | #include < | ||
| + | |||
| + | /* | ||
| + | gcc -Wall -pthread -o test_mysql test_mysql.c -lpigpio -O3 `mysql_config --cflags` `mysql_config --libs` | ||
| + | sudo ./ | ||
| + | */ | ||
| + | |||
| + | |||
| + | int main(int argc, char *argv[]) | ||
| + | { | ||
| + | if (gpioInitialise() < 0) return -1; | ||
| + | |||
| + | MYSQL *con = mysql_init(NULL); | ||
| + | |||
| + | if (con == NULL) | ||
| + | { | ||
| + | fprintf(stderr, | ||
| + | exit(1); | ||
| + | } | ||
| + | |||
| + | if (mysql_real_connect(con, | ||
| + | " | ||
| + | { | ||
| + | fprintf(stderr, | ||
| + | mysql_close(con); | ||
| + | exit(1); | ||
| + | } | ||
| + | |||
| + | if (mysql_query(con, | ||
| + | { | ||
| + | fprintf(stderr, | ||
| + | mysql_close(con); | ||
| + | exit(1); | ||
| + | } | ||
| + | |||
| + | mysql_close(con); | ||
| + | |||
| + | return 0; | ||
| + | } | ||
| + | </ | ||
raspberrypi/mysql.1489235193.txt.gz · Last modified: by aistis
