You can use the MySQL C++ Wrapper which is a set of C++ classes for working with the MySQL library. So the answer is you can use MySQL API for C++. Here is the coding for that :
Code:
#include "mysqlplus.h"
#include <STDIO.H>
void main()
{
sql_connection_c connection( "database",
"localhost", "root", "mypassword" );
sql_query_c query( &connection );
sql_result_c *sql_result = 0;
if ( !query.execute( "select * from customers" ) )
{
printf( "oops... didn't execute!!\n" );
return;
}
sql_result = query.store();
int n_fields = sql_result->n_fields();
for ( int idx = 0; idx < n_fields; idx++ )
{
sql_field_c sql_field = sql_result->fetch_field( idx );
printf( "field %d [%s]\n", idx, sql_field.get_name() );
}
}
Bookmarks