- Timestamp:
- 07/31/18 12:07:31 (6 years ago)
- Location:
- trunk/FACT++/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/fits2sql.cc
r19099 r19101 65 65 ("max", var<int64_t>(int64_t(0)), "Maximum number of events to process (0: all), mainly for test purpose") 66 66 ("engine", var<string>("InnoDB"), "Database engine to be used when a new table is created") 67 ("duplicate", var<string>(""), "Specifies an assignment_list for an 'ON DUPLICATE KEY UPDATE' expression") 67 68 ; 68 69 … … 72 73 ("dry-run", po_switch(), "Skip any query which changes the databse (might result in consecutive failures)") 73 74 ("print-extensions", po_switch(), "Print extensions (tables) from fits file") 74 ("print-columns", po_switch(), "Print columns in fits table")75 ("print-columns", po_switch(), "Print columns in fits table") 75 76 ("print-insert", po_switch(), "Print the INSERT query (note that it contains all data)") 76 77 ("print-create", po_switch(), "Print the CREATE query") … … 94 95 "refer to the output below to get the abbreviations.\n" 95 96 "\n" 96 "This is a general purpose tool to fill the contents of a root file into a database " 97 "as long as this is technically possible and makes sense. Note that root can even " 98 "write complex data like a TH1F into a database, this is not the purpose of this " 99 "program.\n" 100 "\n" 101 "Each root tree has branches and leaves (the basic data types). These leaves can " 102 "be read independently of the classes which were used to write the root file. " 103 "The default tree to read from is 'Events' but the name can be overwritten " 104 "using --tree. The default table name to fill the data into is identical to " 105 "the tree name. It can be overwritten using --table.\n" 106 "\n" 107 "The name of each column to which data is filled from a leave is obtained from " 108 "the leaves' names. The leave names can be checked using --print-leaves. " 109 "A --print-branches exists for convenience to print only the high-level branches. " 110 "Sometimes these names might be quite unconvenient like MTime.fTime.fMilliSec or " 111 "just MHillas.fWidth. To allow to simplify column names, regular expressions " 112 "(using boost's regex) can be defined to change the names. Note that these regular " 113 "expressions are applied one by one on each leaf's name. A valid expression could " 97 "This is a general purpose tool to fill the contents of a fite file into a database.\n" 98 "\n" 99 "Each fits file contians several table, so called extenbsions. Each tables has " 100 "a number of columns compilsed from basic data types. The default extension to " 101 "read from is the first one on the file but the name can be overwritten using " 102 "--extension. The default table name to fill the data into is identical to " 103 "the extension name. It can be overwritten using --table.\n" 104 "\n" 105 "The name of each column to which data is filled is obtained from " 106 "the fits column names. The column names can be checked using --print-columns. " 107 "Sometimes these names might not be convenient. To allow to simplify or replace " 108 "column names, regular expressions (using boost's regex) can be defined to change " 109 "the names. Note that these regular expressions are applied one by one on each " 110 "columns's name. A valid expression could " 114 111 "be:\n" 115 112 " --map=MHillas\\.f/\n" … … 117 114 "once. They are applied in sequence. A single match does not stop the sequence.\n" 118 115 "\n" 119 "Sometimes it might also be convenient to skip a leaf. This can be done with "120 "the --ignore resource. If the given regular expresion yield a match, the "121 " leaf will be ignored. Note that the regular expression workon the raw-name "122 "of the leafnot the readily mapped SQL column names. Example:\n"116 "Sometimes it might also be convenient to skip a column. This can be done with " 117 "the --ignore resource. If the given regular expresion yields a match, the " 118 "column will be ignored. Note that the regular expression works on the raw-name " 119 "of the column not the readily mapped SQL column names. Example:\n" 123 120 " --ignore=ThetaSq\\..*\n" 124 121 "will skip all leaved which start with 'ThetaSq.'. This option can be used" 125 122 "more than once.\n" 126 123 "\n" 127 "The data type of each column is kept as close as possible to the leaves' data "124 "The data type of each column is kept as close as possible to the columns' data " 128 125 "types. If for some reason this is not wanted, the data type of the SQL column " 129 126 "can be overwritten with --sql-type sql-column/sql-ytpe, for example:\n" … … 148 145 "\n" 149 146 "All columns are created as NOT NULL as default and the table is created as " 150 "MyISAM (default).\n" 147 "InnoDB (default).\n" 148 "\n" 149 "Usually, the INSERT query would fail if the PRIMARY key exists already. " 150 "This can be avoided using the 'ON DUPLICATE KEY' directive. With the " 151 "--duplicate,you can specify what should be updated in case of a duplicate key. " 152 "For detaily, see the MySQL manual.\n" 151 153 "\n" 152 154 "For debugging purpose, or to just create or drop a table, the final insert " … … 272 274 273 275 const string engine = conf.Get<string>("engine"); 276 const string duplicate = conf.Get<string>("duplicate"); 274 277 275 278 const bool print_extensions = conf.Get<bool>("print-extensions"); … … 545 548 } 546 549 } 547 query += "\n)"; // ON DUPLICATE KEY UPDATE\n";550 query += "\n)"; 548 551 549 552 count ++; 550 553 } 554 555 if (!duplicate.empty()) 556 query += "\nON DUPLICATE KEY UPDATE\n " + duplicate; 551 557 552 558 if (verbose>0) … … 591 597 cout << count << " row(s) inserted.\n\n"; 592 598 cout << "Total execution time: " << Time().UnixTime()-start.UnixTime() << "s\n" << endl; 599 /* 600 try 601 { 602 const auto resw = 603 connection.query("SHOW WARNINGS").store(); 604 605 if (resw.num_rows()>0) 606 cout << "\nWARNINGS:\n\n"; 607 608 for (size_t i=0; i<resw.num_rows(); i++) 609 { 610 const mysqlpp::Row &roww = resw[i]; 611 612 cout << roww["Level"] << '[' << roww["Code"] << "]: "; 613 cout << roww["Message"] << '\n' << endl; 614 } 615 616 } 617 catch (const exception &e) 618 { 619 cerr << "\nSHOW WARNINGS\n\n"; 620 cerr << "SQL query failed:\n" << e.what() << endl; 621 return 6; 622 }*/ 593 623 } 594 624 -
trunk/FACT++/src/root2sql.cc
r19089 r19101 61 61 ("max", var<int64_t>(int64_t(0)), "Maximum number of events to process (0: all), mainly for test purpose") 62 62 ("engine", var<string>("InnoDB"), "Database engine to be used when a new table is created") 63 ("duplicate", var<string>(""), "Specifies an assignment_list for an 'ON DUPLICATE KEY UPDATE' expression") 63 64 ; 64 65 … … 114 115 "\n" 115 116 "Sometimes it might also be convenient to skip a leaf. This can be done with " 116 "the --ignore resource. If the given regular expresion yield a match, the "117 "leaf will be ignored. Note that the regular expression work on the raw-name "117 "the --ignore resource. If the given regular expresion yields a match, the " 118 "leaf will be ignored. Note that the regular expression works on the raw-name " 118 119 "of the leaf not the readily mapped SQL column names. Example:\n" 119 120 " --ignore=ThetaSq\\..*\n" … … 144 145 "\n" 145 146 "All columns are created as NOT NULL as default and the table is created as " 146 "MyISAM (default).\n" 147 "InnoDB (default).\n" 148 "\n" 149 "Usually, the INSERT query would fail if the PRIMARY key exists already. " 150 "This can be avoided using the 'ON DUPLICATE KEY' directive. With the " 151 "--duplicate,you can specify what should be updated in case of a duplicate key. " 152 "For detaily, see the MySQL manual.\n" 147 153 "\n" 148 154 "For debugging purpose, or to just create or drop a table, the final insert " … … 291 297 292 298 const string engine = conf.Get<string>("engine"); 299 const string duplicate = conf.Get<string>("duplicate"); 293 300 294 301 const bool print_branches = conf.Get<bool>("print-branches"); … … 550 557 query += " /* "+c->column+" -> "+c->branch+" */"; 551 558 } 552 query += "\n)"; // ON DUPLICATE KEY UPDATE\n";559 query += "\n)"; 553 560 554 561 count ++; 555 562 } 563 564 if (!duplicate.empty()) 565 query += "\nON DUPLICATE KEY UPDATE\n " + duplicate; 556 566 557 567 if (verbose>0) … … 596 606 cout << count << " row(s) inserted.\n\n"; 597 607 cout << "Total execution time: " << Time().UnixTime()-start.UnixTime() << "s\n" << endl; 598 } 608 /* 609 try 610 { 611 const auto resw = 612 connection.query("SHOW WARNINGS").store(); 613 614 if (resw.num_rows()>0) 615 cout << "\nWARNINGS:\n\n"; 616 617 for (size_t i=0; i<resw.num_rows(); i++) 618 { 619 const mysqlpp::Row &roww = resw[i]; 620 621 cout << roww["Level"] << '[' << roww["Code"] << "]: "; 622 cout << roww["Message"] << '\n' << endl; 623 } 624 625 } 626 catch (const exception &e) 627 { 628 cerr << "\nSHOW WARNINGS\n\n"; 629 cerr << "SQL query failed:\n" << e.what() << endl; 630 return 6; 631 }*/ 632 } 633 599 634 600 635 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.