~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to examples/simple.cc

  • Committer: Olaf van der Spek
  • Date: 2011-08-11 12:49:52 UTC
  • mto: This revision was merged to the branch mainline in revision 2397.
  • Revision ID: olafvdspek@gmail.com-20110811124952-43a9kgwf3366k0kt
Add drizzle::query_c

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
  const char* password= NULL;
53
53
  bool mysql= false;
54
54
  in_port_t port= 0;
55
 
  const char* query= "select table_schema, table_name from tables";
56
55
  drizzle_verbose_t verbose= DRIZZLE_VERBOSE_NEVER;
57
56
 
58
57
  for (int c; (c = getopt(argc, argv, "d:h:mp:u:P:q:v")) != -1; )
83
82
      password = optarg;
84
83
      break;
85
84
 
86
 
    case 'q':
87
 
      query= optarg;
88
 
      break;
89
 
 
90
85
    case 'v':
91
86
      if (verbose < DRIZZLE_VERBOSE_MAX)
92
87
        verbose= static_cast<drizzle_verbose_t>(verbose + 1);
94
89
 
95
90
    default:
96
91
      cout << 
97
 
        "usage: " << argv[0] << " [-d <db>] [-h <host>] [-m] [-p <port>] [-q <query>] [-v]\n"
 
92
        "usage:\n"
98
93
        "\t-d <db>    - Database to use for query\n"
99
94
        "\t-h <host>  - Host to connect to\n"
100
95
        "\t-m         - Use the MySQL protocol\n"
116
111
  con->set_auth(user, password);
117
112
  con->set_db(db);
118
113
  drizzle::result_c result;
119
 
  if (con->query(result, query))
 
114
  drizzle::query_c q(*con, "select table_schema, table_name from tables where table_name like ?");
 
115
  q.p("%");
 
116
  cout << q.read() << endl;
 
117
  if (q.execute(result))
120
118
  {
121
119
    cerr << "query: " << con->error() << endl;
122
120
    return 1;