Changeset 19103 for trunk/FACT++/src/root2sql.cc
- Timestamp:
- 07/31/18 13:48:35 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/root2sql.cc
r19102 r19103 62 62 ("engine", var<string>("InnoDB"), "Database engine to be used when a new table is created") 63 63 ("duplicate", var<string>(""), "Specifies an assignment_list for an 'ON DUPLICATE KEY UPDATE' expression") 64 ("ignore-errors", po_switch(), "Adds the IGNORE keyword to the INSERT query (turns errors into warnings, ignores rows with errors)") 64 65 ; 65 66 … … 159 160 "end.\n" 160 161 "\n" 162 "Another possibility is to add the IGNORE keyword to the INSERT query by " 163 "--ignore-errors, which essentially ignores all errors and turns them into " 164 "warnings which are printed after the query succeeded.\n" 165 "\n" 161 166 "Using a higher verbosity level (-v), an overview of the written columns or all " 162 167 "processed leaves is printed depending on the verbosity level. The output looks " … … 301 306 const string duplicate = conf.Get<string>("duplicate"); 302 307 308 const bool ignore_errors = conf.Get<bool>("ignore-errors"); 309 303 310 const bool print_branches = conf.Get<bool>("print-branches"); 304 311 const bool print_leaves = conf.Get<bool>("print-leaves"); … … 452 459 // Checking for database connection 453 460 461 Database connection(uri); 462 454 463 try 455 464 { 456 465 if (!force) 457 Database(uri).connected();466 connection.connected(); 458 467 } 459 468 catch (const exception &e) … … 485 494 // => Simple result 486 495 if (!dry_run) 487 Database(uri).query("DROP TABLE `"+table+"`").execute();496 connection.query("DROP TABLE `"+table+"`").execute(); 488 497 if (verbose>0) 489 498 cout << "Table `" << table << "` dropped." << endl; … … 500 509 { 501 510 if (create && !dry_run) 502 Database(uri).query(query).execute();511 connection.query(query).execute(); 503 512 } 504 513 catch (const exception &e) … … 521 530 522 531 //query = update ? "UPDATE" : "INSERT"; 523 query = "INSERT `"+table+"`\n" 532 query = "INSERT "; 533 if (ignore_errors) 534 query += "IGNORE "; 535 query += "`"+table+"`\n" 524 536 "(\n"; 525 537 … … 589 601 if (!noinsert && !dry_run) 590 602 // => Simple result 591 Database(uri).query(query).execute();603 connection.query(query).execute(); 592 604 else 593 605 cout << "Insert query skipped!" << endl; … … 608 620 cout << count << " row(s) inserted.\n\n"; 609 621 cout << "Total execution time: " << Time().UnixTime()-start.UnixTime() << "s\n" << endl; 610 /* 622 611 623 try 612 624 { … … 622 634 623 635 cout << roww["Level"] << '[' << roww["Code"] << "]: "; 624 cout << roww["Message"] << '\n' << endl;636 cout << roww["Message"] << '\n'; 625 637 } 638 cout << endl; 626 639 627 640 } … … 630 643 cerr << "\nSHOW WARNINGS\n\n"; 631 644 cerr << "SQL query failed:\n" << e.what() << endl; 632 return 6; 633 }*/ 634 } 635 645 return 7; 646 } 647 } 636 648 637 649 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.