#include <stdlib.h>
#include <mysql/mysql.h>
int main(int argc, char *argv[])
{
MYSQL *my_con = malloc( sizeof(MYSQL) )
MYSQL_RES *my_res
MYSQL_FIELD *my_field
MYSQL_ROW my_row
int rows, i
int res
int a[2] = {51,2}
printf("%3d ",a[0])
mysql_init(my_con)
my_con = mysql_real_connect(my_con, "localhost", "root", "jwn.com",
"jwn", 0, NULL, CLIENT_FOUND_ROWS)
if( NULL == my_con )
error_quit("Connection fail", my_con)
printf("Connection success\n")
res = mysql_query(my_con,
"insert into class1(name, age, birthday) value('abc', 52, NOW())")
mysql_free_result(my_res)
mysql_close(my_con)
free(my_con)
return 0
}
mysql是有c语言接口的,安装相应库后就可以链接了,一般连接mysql的函数是mysql_connect或者mysql_real_connect(大概就是这么拼的吧。。。)可以使用mysql_query执行sql语句欢迎分享,转载请注明来源:内存溢出
评论列表(0条)