47
47
int main(int argc, char *argv[])
49
const char* db= "information_schema";
50
49
const char* host= NULL;
51
50
const char* user= NULL;
52
51
const char* password= NULL;
55
const char* query= "select table_schema, table_name from tables";
56
drizzle_verbose_t verbose= DRIZZLE_VERBOSE_NEVER;
58
54
for (int c; (c = getopt(argc, argv, "d:h:mp:u:P:q:v")) != -1; )
75
63
port= static_cast<in_port_t>(atoi(optarg));
91
if (verbose < DRIZZLE_VERBOSE_MAX)
92
verbose= static_cast<drizzle_verbose_t>(verbose + 1);
97
"usage: " << argv[0] << " [-d <db>] [-h <host>] [-m] [-p <port>] [-q <query>] [-v]\n"
98
"\t-d <db> - Database to use for query\n"
99
77
"\t-h <host> - Host to connect to\n"
100
"\t-m - Use the MySQL protocol\n"
101
78
"\t-p <port> - Port to connect to\n"
102
79
"\t-u <user> - User\n"
103
"\t-P <pass> - Password\n"
104
"\t-q <query> - Query to run\n"
105
"\t-v - Increase verbosity level\n";
80
"\t-P <pass> - Password\n";
110
85
drizzle::drizzle_c drizzle;
111
drizzle_set_verbose(&drizzle.b_, verbose);
112
86
drizzle::connection_c* con= new drizzle::connection_c(drizzle);
114
drizzle_con_add_options(&con->b_, DRIZZLE_CON_MYSQL);
115
87
con->set_tcp(host, port);
116
88
con->set_auth(user, password);
89
con->set_db("information_schema");
118
90
drizzle::result_c result;
119
if (con->query(result, query))
91
drizzle::query_c q(*con, "select table_schema, table_name from tables where table_name like ?");
93
cout << q.read() << endl;
94
if (q.execute(result))
121
96
cerr << "query: " << con->error() << endl;