#include #include #include #include #include #include using namespace std; #define DB_HOST "localhost" #define DB_USER "root" #define DB_PASSW "" #define DB_NAME "test" #define DB_PORT 3309 #define DB_UNIX_SOCKET NULL void main( void ) { MYSQL mysql; int x; string q_table, num; mysql_init(&mysql); if (!mysql_real_connect(&mysql,DB_HOST,DB_USER,DB_PASSW,DB_NAME,DB_PORT,DB_UNIX_SOCKET,0)) { printf("Error: %s\n",mysql_error(&mysql)); return; } else printf("Connected to the server: %s\n",mysql_get_server_info(&mysql)); q_table = "Create Table if not exists tb (id int,"; for (x = 0; x <= 1000; x++) { stringstream out; q_table += "id"; out << x; num = out.str(); q_table += num; q_table += " int"; if ( x < 1000 ) q_table += ","; } q_table += ") engine = MyISAM"; if (mysql_query( &mysql, q_table.c_str() )) { printf("Error (query): %s\n", mysql_error( &mysql )); mysql_close( &mysql ); return; } mysql_close(&mysql); }