garten

view db.h @ 3:0c19ad487f02

first weather implementation (static values)
author meillo@marmaro.de
date Wed, 14 May 2008 21:09:09 +0200
parents
children 32c4212f05d9
line source
1 /*
2 * data for the database connection
3 */
5 char* server = "localhost";
6 char* user = "garten";
7 char* password = "gras";
8 char* database = "garten";
10 MYSQL* conn;
11 MYSQL_RES* result;
12 MYSQL_ROW row;
15 void db_connect() {
16 conn = mysql_init(NULL);
18 /* Connect to database */
19 if (!mysql_real_connect(conn, server, user, password, database, 0, NULL, 0)) {
20 fprintf(stderr, "%s\n", mysql_error(conn));
21 exit(1);
22 }
23 }
26 void db_close() {
27 /* close connection */
28 mysql_close(conn);
29 }
32 void db_query(char* query) {
33 int error;
34 /* send SQL query */
35 error = mysql_query(conn, query);
36 printf("query: %s\nerror: %d / %d\n", query, error, mysql_errno(conn));
37 if (error != 0) {
38 fprintf(stderr, "E: %s\n", mysql_error(conn));
39 }
40 }