From: Florian G. <re...@us...> - 2007-03-06 23:57:06
|
Update of /cvsroot/perfparse/_perfparse/db_tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5644/db_tools Modified Files: convert.c Log Message: work in progress ... Index: convert.c =================================================================== RCS file: /cvsroot/perfparse/_perfparse/db_tools/convert.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** convert.c 4 Mar 2007 00:08:07 -0000 1.13 --- convert.c 6 Mar 2007 23:57:04 -0000 1.14 *************** *** 60,63 **** --- 60,64 ---- void addTableRawSummary (); void addTableRawSummaryData (); + void pp_mysql_convert_sql_failure(char*f,int l, const char*str, const char *error); *************** *** 121,124 **** --- 122,133 ---- int iNDBport; + + MYSQL db_mysql_old; + MYSQL_RES *query_result_old = NULL; + MYSQL_ROW result_row_old; + MYSQL db_mysql_new; + MYSQL_RES *query_result_new = NULL; + MYSQL_ROW result_row_new; + printf(_("The database schema for perfparse changed dramatically. ")); printf(_("Changing the tables\nwould be too error-prone, so we decided to copy the data into a new database.\n")); *************** *** 189,194 **** --- 198,258 ---- } + // new database connection + if(yesno == 'n') { // copy connection information + sNDBhost=config_get_value_as_string(CONFIG_ITEM_ID_DB_HOST); + sNDBuser=config_get_value_as_string(CONFIG_ITEM_ID_DB_USER); + sNDBpass=config_get_value_as_string(CONFIG_ITEM_ID_DB_PWD); + sNDBdatabase=config_get_value_as_string(CONFIG_ITEM_ID_DB_DATABASE); + iNDBport=config_get_value_as_integer(CONFIG_ITEM_ID_DB_PORT); + sNDBsocket=config_get_value_as_string(CONFIG_ITEM_ID_DB_SOCKET); + } else { //ask user + printf(_("Please enter the connection data for the new database below:\n")); + + sNDBhost=malloc(65); + printf(_("Database Host: ")); + fscanf(stdin,"%s64",sNDBhost); + + sNDBuser=malloc(65); + printf(_("Database User: ")); + fscanf(stdin,"%s64",sNDBuser); + + sNDBpass=malloc(65); + printf(_("Database Password: ")); + fscanf(stdin,"%s64",sNDBpass); + + sNDBdatabase=malloc(65); + printf(_("Database Name: ")); + fscanf(stdin,"%s64",sNDBdatabase); + + printf(_("Database Port: ")); + fscanf(stdin,"%d",&iNDBport); + + sNDBsocket=malloc(65); + printf(_("Database Socket: ")); + fscanf(stdin,"%s64",sNDBsocket); + } + // connect to old databases + + if (!mysql_init (&db_mysql_old)) { + printf(_("Cannot initialise MySQL\n")); + exit(EXIT_FAILURE); + } + if (!mysql_real_connect(&db_mysql_old, + sODBhost,sODBuser,sODBpass,sODBdatabase, + iODBport,sODBsocket,0)) { + printf(_("Cannot connect to old database. Errormessage: %s")); + exit(EXIT_FAILURE); + } + + if (!mysql_real_connect(&db_mysql_new, + sNDBhost,sNDBuser,sNDBpass,sNDBdatabase, + iNDBport,sNDBsocket,0)) { + printf(_("Cannot connect to new database. Errormessage: %s")); + exit(EXIT_FAILURE); + } + + /* int i_steps=20; *************** *** 341,344 **** --- 405,412 ---- } + void pp_mysql_convert_sql_failure(char*f,int l, const char*str, const char *error) { + printf(f,l,"%s (%s)",str,error); + exit(EXIT_FAILURE); + } void setConversionStep(int i) { |