InfiniBand

Mellanox InfiniBand卡线缆性能延迟性测试程序源码,C源码实现操作mysql库,实现简单的增删改查,代码当前用的是增插入20000条数据

具体见源码

 #include <mysql/mysql.h>
#include <time.h>
#include <stdio.h>
//gcc $0 -L /usr/lib64/mysql/ -lmysqlclient -o outputname
//Mellanox InfiniBand Card Perforce test,By yodoo ruiy
// void insert() {
MYSQL *conn;
MYSQL_RES *res;
MYSQL_ROW row; char *server = "192.168.3.205";
char *user = "root";
char *password = ""; /* set me first */
char *database = "ruiy";
//char *query = "select * from user";
//char *query = "insert into perforce values("rui_C","rui_S","rui_N","rui_v","rui_O","rui_U","rui_T","rui_S","rui_CO","rui_All");";
//char *query = "insert into perforce values('rui_C','rui_S','rui_N','rui_v','rui_O','rui_U','rui_T','rui_S','rui_CO','rui_All');"
char *query = "insert into perforce values(\"rui_C\",\"rui_S\",\"rui_N\",\"rui_v\",\"rui_O\",\"rui_U\",\"rui_T\",\"rui_S\",\"rui_CO\",\"rui_All\")";
int t,r; conn = mysql_init(NULL); if(!mysql_real_connect(conn,server,user,password,database,,NULL,))
{
printf("Error connecting to database: %s\n", mysql_error(conn));
}
else
{
printf("Connected....\n");
} t = mysql_query(conn, query); if(t)
{
printf("Error making query: %s\n", mysql_error(conn));
}
else
{
printf("Query made...\n");
res = mysql_use_result(conn);
if(res)
{
for(r=; r<=mysql_field_count(conn); r++)
{
row = mysql_fetch_row(res);
if(row<) break;
for(t=; t<mysql_num_fields(res); t++)
printf("%s", row[t]);
printf("\n");
}
}
mysql_free_result(res);
}
mysql_close(conn);
} void Ptime()
{
FILE *fp;
time_t now;
struct tm *timenow;
time(&now);
timenow = localtime(&now);
fp = fopen("time.xml","a+");
fprintf(fp,"%s",asctime(timenow));
fclose(fp);
} main()
{ Ptime();
int i;
for (i=;i<;i++)
insert();
Ptime();
return ;
}
上一篇:js代码大全(各种方法、属性)《转载》


下一篇:equals()源代码及释义