Changeset 19126 for trunk/FACT++


Ignore:
Timestamp:
08/03/18 13:46:37 (6 years ago)
Author:
tbretz
Message:
Implemented the possibility to print basic connection informations.
Location:
trunk/FACT++/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/fits2sql.cc

    r19125 r19126  
    7272        ("dry-run",        po_switch(),               "Skip any query which changes the databse (might result in consecutive failures)")
    7373        ("print-extensions", po_switch(),             "Print extensions (tables) from fits file")
     74        ("print-connection", po_switch(),             "Print database connection information")
    7475        ("print-columns",  po_switch(),               "Print columns in fits table")
    7576        ("print-insert",   po_switch(),               "Print the INSERT query (note that it contains all data)")
     
    300301    const bool ignore_errors     = conf.Get<bool>("ignore-errors");
    301302
     303    const bool print_connection  = conf.Get<bool>("print-connection");
    302304    const bool print_extensions  = conf.Get<bool>("print-extensions");
    303305    const bool print_columns     = conf.Get<bool>("print-columns");
     
    461463    Database connection(uri);
    462464
     465    if (print_connection)
     466    {
     467        try
     468        {
     469            const auto &res1 = connection.query("SHOW STATUS LIKE 'Compression'").store();
     470            cout << "Compression of databse connection is " << string(res1[0][1]) << endl;
     471
     472            const auto &res2 = connection.query("SHOW STATUS LIKE 'Ssl_cipher'").store();
     473            cout << "Connection to databases is " << (string(res2[0][1]).empty()?"UNENCRYPTED":"ENCRYPTED ("+string(res2[0][1])+")") << endl;
     474        }
     475        catch (const exception &e)
     476        {
     477            cerr << "\nSHOW STATUS LIKE COMPRESSION\n\n";
     478            cerr << "SQL query failed:\n" << e.what() << endl;
     479            return 6;
     480        }
     481    }
     482
    463483    try
    464484    {
  • trunk/FACT++/src/root2sql.cc

    r19125 r19126  
    7474        ("no-insert",      po_switch(),               "Does not insert any data into the table")
    7575        ("dry-run",        po_switch(),               "Skip any query which changes the databse (might result in consecutive failures)")
     76        ("print-connection", po_switch(),             "Print database connection information")
    7677        ("print-branches", po_switch(),               "Print the branches found in the tree")
    7778        ("print-leaves",   po_switch(),               "Print the leaves found in the tree (this is what is processed)")
     
    316317    const bool ignore_errors     = conf.Get<bool>("ignore-errors");
    317318
     319    const bool print_connection  = conf.Get<bool>("print-connection");
    318320    const bool print_branches    = conf.Get<bool>("print-branches");
    319321    const bool print_leaves      = conf.Get<bool>("print-leaves");
     
    478480        cerr << "SQL connection failed: " << e.what() << '\n' << endl;
    479481        return 3;
     482    }
     483
     484    if (print_connection)
     485    {
     486        try
     487        {
     488            const auto &res1 = connection.query("SHOW STATUS LIKE 'Compression'").store();
     489            cout << "Compression of databse connection is " << string(res1[0][1]) << endl;
     490
     491            const auto &res2 = connection.query("SHOW STATUS LIKE 'Ssl_cipher'").store();
     492            cout << "Connection to databases is " << (string(res2[0][1]).empty()?"UNENCRYPTED":"ENCRYPTED ("+string(res2[0][1])+")") << endl;
     493        }
     494        catch (const exception &e)
     495        {
     496            cerr << "\nSHOW STATUS LIKE COMPRESSION\n\n";
     497            cerr << "SQL query failed:\n" << e.what() << endl;
     498            return 6;
     499        }
    480500    }
    481501
  • trunk/FACT++/src/rootifysql.cc

    r19121 r19126  
    2424    po::options_description control("Rootify SQL");
    2525    control.add_options()
    26         ("uri,u",         var<string>()->required(),   "Database link as in\n\tuser:password@server[:port]/database.")
     26        ("uri,u",         var<string>()->required(),   "Database link as in\n\tuser:password@server[:port]/database[/comp].")
    2727        ("query,q",       var<string>(""),             "MySQL query (overwrites --file)")
    2828        ("file",          var<string>("rootify.sql"),  "An ASCII file with the MySQL query (overwrites --query)")
     
    4444        ("env.*",         vars<string>(),              "Predefined environment for substitutions in the query ($ENV)")
    4545        ("list.*",        var<string>(),               "Predefined environment for substitutions in the query ($ENV). The list is read from the given file (one list entry per line)")
     46        ("print-connection", po_switch(),              "Print database connection information")
    4647        ("verbose,v",     var<uint16_t>(1),            "Verbosity (0: quiet, 1: default, 2: more, 3, ...)")
    4748        ;
     
    384385    const string   delimiter   = conf.Get<string>("delimiter");
    385386    const vector<string> _ignore = conf.Vec<string>("ignore");
     387    const bool  print_connection = conf.Get<bool>("print-connection");
    386388    //const vector<Map> mymap    = conf.Vec<Map>("map");
    387389
     
    494496
    495497    Database connection(uri); // Keep alive while fetching rows
     498
     499    if (print_connection)
     500    {
     501        try
     502        {
     503            const auto &res1 = connection.query("SHOW STATUS LIKE 'Compression'").store();
     504            cout << "Compression of databse connection is " << string(res1[0][1]) << endl;
     505
     506            const auto &res2 = connection.query("SHOW STATUS LIKE 'Ssl_cipher'").store();
     507            cout << "Connection to databases is " << (string(res2[0][1]).empty()?"UNENCRYPTED":"ENCRYPTED ("+string(res2[0][1])+")") << endl;
     508        }
     509        catch (const exception &e)
     510        {
     511            cerr << "\nSHOW STATUS LIKE COMPRESSION\n\n";
     512            cerr << "SQL query failed:\n" << e.what() << endl;
     513            return 6;
     514        }
     515    }
    496516
    497517    try
Note: See TracChangeset for help on using the changeset viewer.