/* This file is part of Bolixo. Bolixo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Bolixo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Bolixo. If not, see . */ /* Execute SQL and print statitics */ #include #include #include #include #include #include #include using namespace std; int main (int argc, char *argv[]) { glocal int ret = -1; glocal const char *dbserv = "localhost"; glocal const char *dbname = "files"; glocal const char *dbuser = "root"; glocal const char *dbpass = NULL; glocal string sql = "select count(*) from dirs_content"; glocal const char *sqlfile = NULL; glocal bool printres = false; static const char *tb[]={"bolixo","tlmpsql",NULL}; glocal.ret = (argc,argv,tb); setproginfo ("","0.0","..."); setarg ('s',"server","Database server",glocal.dbserv,false); setarg ('p',"password","Database password",glocal.dbpass,true); setarg ('q',"query","Database query",glocal.sql,false); setarg ('Q',"queryfile","File holding a query",glocal.sqlfile,false); setarg (' ',"printres","Print the results",glocal.printres,false); int ret = -1; query_setdefaultdb (glocal.dbserv,glocal.dbname,glocal.dbuser,glocal.dbpass); query_getdefaultdb()->setunixpath ("/var/lib/lxc/bosqlddata/rootfs/var/lib/mysql/mysql.sock"); if (glocal.sqlfile != NULL){ glocal.sql.clear(); (glocal.sqlfile,false); glocal.sql += line; return 0; } for (int i=0; i<10; i++){ glocal long long start = fdpass_getnow(); glocal long long end = glocal.start; (glocal.sql.c_str()); if (rownum == 0){ glocal.end = fdpass_getnow(); } if (glocal.printres) printf ("\t%s\n",row[0]); long long duration = glocal.end - glocal.start; printf ("duration: %Ld.%06Ld\n",duration/1000000,duration%1000000); } return ret; return glocal.ret; }