Ignore:
Timestamp:
08/03/18 13:46:37 (6 years ago)
Author:
tbretz
Message:
Implemented the possibility to print basic connection informations.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.