mysql_real_query - can I do an insert?
<snip>
'--------------
include "CommandLineTool"
BeginCDeclaration
#include "/usr/include/mysql/mysql.h"
#include <stdio.h>
#include <string.h>
int Test();
EndC
BeginCFunction
int Test() {
MYSQL mysql;
MYSQL_RES *res;
MYSQL_ROW row;
MYSQL_FIELD *fields;
char query[80];
mysql_init(&mysql);
int i, num_fields;
mysql_real_connect(&mysql,"localhost","username","password","schema",0,NULL,0);
// sprintf(query,"SHOW COLUMNS FROM application_user");
sprintf(query,"DESCRIBE application_user");
mysql_real_query(&mysql,query,(unsigned int)strlen(query));
res = mysql_use_result(&mysql);
num_fields = mysql_num_fields(res);
// while((field = mysql_fetch_field(res))) {
// if (IS_NUM(field->type))
// printf("field type is number\n");
// else
// printf("field name %s\n", field->name);
// }
fields = mysql_fetch_fields(res);
printf("Name \t Type \n");
for(i = 0; i < num_fields; i++) {
printf("%s (%d) \t", fields.name, fields.type);
}
printf("\n");
char *fieldName;
while(row = mysql_fetch_row(res)) {
for(i = 0; i < num_fields; i++) {
if (IS_NUM(row))
printf( "%d\t", row );
else
printf( "%s\t", row );
}
printf( "\n" );
}
mysql_free_result(res);
}
EndC
toolbox fn Test = SInt32
// main
fn Test
'--------------
</snip>