⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 insert.c

📁 在Linux操作系统下的C语言进行MySQL进行增删改查
💻 C
字号:
#include <stdio.h>#include <stdlib.h>#include "/usr/include/mysql/mysql.h"int main(int argc,char *argv[]){  MYSQL my_connection;  int res;  mysql_init(&my_connection);  if(mysql_real_connect(&my_connection,"localhost","root","123456","peims",0,NULL,CLIENT_FOUND_ROWS))    {      printf("connection success\n");      res=mysql_query(&my_connection,"insert into student values('','langying','beijing','1949-10-01')");      if(!res)	{	  printf("Inserted %lu rows\n",(unsigned long)mysql_affected_rows(&my_connection));	}      else	{	  fprintf(stderr,"Insert error %d:%s\n",mysql_errno(&my_connection),mysql_error(&my_connection));	}      mysql_close(&my_connection);    }  else    {      fprintf(stderr,"connection failed\n");      if(mysql_errno(&my_connection))	{	  fprintf(stderr,"connection error %d:%s\n",mysql_errno(&my_connection),mysql_error(&my_connection));	}    }  return EXIT_SUCCESS;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -