Ignore:
Timestamp:
04/12/21 09:15:58 (4 years ago)
Author:
tbretz
Message:
Added printing of connection information and a default query on all in rootifysql
File:
1 edited

Legend:

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

    r20011 r20056  
    2525    control.add_options()
    2626        ("uri,u",         var<string>()->required(),   "Database link as in\n\tuser:password@server[:port]/database[?compress=0|1].")
    27         ("query,q",       var<string>(""),             "MySQL query (overwrites --file)")
     27        ("query,q",       var<string>(""),             "MySQL query (overwrites --file, used as table name if without spaces)")
    2828        ("file",          var<string>("rootify.sql"),  "An ASCII file with the MySQL query (overwrites --query)")
    2929        ("ignore-null,i", po_switch(),                 "Do not skip rows containing any NULL field")
     
    9595        "\n"
    9696        "The default is to read the query from a file called rootify.sql. Except if a different "
    97         "filename is specified by the --file option or a query is given with --query.\n"
     97        "filename is specified by the --file option or a query is given with --query. "
     98        "A special case is if the 'query' does not contain any whitespace. Then the "
     99        "query is considered as a table name and the query 'SELECT * FROM table' is "
     100        "executed.\n"
    98101        "\n"
    99102        "As a trick, the rootify.sql file can be made excutable (chmod u+x rootify.sql). "
     
    469472void Convert(FileEntry::Container &container, const mysqlpp::String &col)
    470473{
    471     *reinterpret_cast<T*>(container.ptr) = static_cast<T>(col);
     474    *reinterpret_cast<T*>(container.ptr) = col.is_null() ? T(0) : static_cast<T>(col);
    472475}
    473476
     
    534537
    535538    string query  = conf.Get<string>("query");
     539    if (!query.empty() && query.find_first_of(' ')==string::npos)
     540        query.insert(0, "SELECT * FROM ");
     541
    536542    if (query.empty())
    537543    {
     
    635641    }
    636642
    637     Database connection(uri); // Keep alive while fetching rows
     643    Database connection(uri, print_connection); // Keep alive while fetching rows
    638644
    639645    if (verbose>0)
Note: See TracChangeset for help on using the changeset viewer.