I am working on a problem where I need to store and retrive the data from the database . I am using C for that on windows system . I am familiar with MYSQL database . I just need to know whether its possible for me to access database using C if yes which IDE I can use and how can I connect it to MYSQL .
3 Answers
Yes, you can connect your C code to MySQL using a connector (driver) available on MySql home page: http://www.mysql.com/products/connector/
There is a nice tutorial on writing C programs accessing MySQL: MySQL C API programming tutorial
You can use any IDE you want for writing your code, for example Visual Studio. Here you can download a free version: http://www.microsoft.com/visualstudio/11/en-us/products/express
Comments
Yes, of course you can. You just need to download MySQL libraries. Here simple example of how to use it:
#include <stdio.h>
#include "mysql/mysql.h"
int main() {
MYSQL mysql;
if(mysql_init(&mysql)==NULL) {
printf("\nInitialization error\n");
return 0;
}
mysql_real_connect(&mysql,"localhost","user","pass","dbname",0,NULL,0);
printf("Client version: %s",mysql_get_client_info());
printf("\nServer version: %s",mysql_get_server_info(&mysql));
mysql_close(&mysql);
return 1;
}
You can use anyone IDE you want to. All you need is to set paths for include, lib and bin folders in MySQL.
I write a library in C++ for database access. With this library you can connect e retrieve data from postgresql, mysql and mysql.
You can get the code here: https://github.com/vitorluis/VSQL
And you can try out this library and share with other people.