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

Go to the source code of this file.
Defines | |
| #define | INSERT_QUERY "insert into test (name,num) values ('item %d', %d)" |
Functions | |
| int | main (int argc, char **argv) |
| #define INSERT_QUERY "insert into test (name,num) values ('item %d', %d)" |
| int main | ( | int | argc, | |
| char ** | argv | |||
| ) |
Definition at line 24 of file insert_test.c.
References atoi(), count, exit, INSERT_QUERY, mysql, mysql_close(), mysql_error(), mysql_init(), mysql_query(), mysql_real_connect(), NULL, perror(), st_mysql::reconnect, and sock.
00025 { 00026 int count,num; 00027 MYSQL *sock,mysql; 00028 char qbuf[160]; 00029 00030 if (argc != 3) 00031 { 00032 fprintf(stderr,"usage : insert_test <dbname> <Num>\n\n"); 00033 exit(1); 00034 } 00035 00036 mysql_init(&mysql); 00037 if (!(sock = mysql_real_connect(&mysql,NULL,NULL,NULL,argv[1],0,NULL,0))) 00038 { 00039 fprintf(stderr,"Couldn't connect to engine!\n%s\n",mysql_error(&mysql)); 00040 perror(""); 00041 exit(1); 00042 } 00043 mysql.reconnect= 1; 00044 00045 num = atoi(argv[2]); 00046 count = 0; 00047 while (count < num) 00048 { 00049 sprintf(qbuf,INSERT_QUERY,count,count); 00050 if(mysql_query(sock,qbuf)) 00051 { 00052 fprintf(stderr,"Query failed (%s)\n",mysql_error(sock)); 00053 exit(1); 00054 } 00055 count++; 00056 } 00057 mysql_close(sock); 00058 exit(0); 00059 return 0; 00060 }
Here is the call graph for this function:

1.4.7

