#include <stdio.h>#include <stdlib.h>#include "mysql.h"Include dependency graph for showdb_test.c:

Go to the source code of this file.
Defines | |
| #define | SELECT_QUERY "select name from test where num = %d" |
Functions | |
| int | main (int argc, char **argv) |
Definition at line 25 of file showdb_test.c.
| int main | ( | int | argc, | |
| char ** | argv | |||
| ) |
Definition at line 28 of file showdb_test.c.
References atoi(), count, exit, mysql, mysql_close(), mysql_error(), mysql_free_result(), mysql_init(), mysql_list_dbs(), mysql_num_rows(), mysql_real_connect(), NULL, perror(), st_mysql::reconnect, SELECT_QUERY, and sock.
00029 { 00030 int count, num; 00031 MYSQL mysql,*sock; 00032 MYSQL_RES *res; 00033 char qbuf[160]; 00034 00035 if (argc != 3) 00036 { 00037 fprintf(stderr,"usage : select_test <dbname> <num>\n\n"); 00038 exit(1); 00039 } 00040 00041 mysql_init(&mysql); 00042 if (!(sock = mysql_real_connect(&mysql,NULL,0,0,argv[1],0,NULL,0))) 00043 { 00044 fprintf(stderr,"Couldn't connect to engine!\n%s\n\n",mysql_error(&mysql)); 00045 perror(""); 00046 exit(1); 00047 } 00048 mysql.reconnect= 1; 00049 00050 count = 0; 00051 num = atoi(argv[2]); 00052 while (count < num) 00053 { 00054 sprintf(qbuf,SELECT_QUERY,count); 00055 if(!(res=mysql_list_dbs(sock,NULL))) 00056 { 00057 fprintf(stderr,"Query failed (%s)\n",mysql_error(sock)); 00058 exit(1); 00059 } 00060 printf("number of fields: %d\n",mysql_num_rows(res)); 00061 mysql_free_result(res); 00062 count++; 00063 } 00064 mysql_close(sock); 00065 exit(0); 00066 return 0; /* Keep some compilers happy */ 00067 }
Here is the call graph for this function:

1.4.7

