Boost logo

Boost :

From: Brian Braatz (brianb_at_[hidden])
Date: 2004-10-15 12:58:03


> -----Original Message-----
> On Behalf Of Jonathan Wakely
> On Fri, Oct 15, 2004 at 10:56:58AM -0600, Brian Braatz wrote:
>
> > As a user I would like to see something along the lines of DTL \
Mysql++
> >
> > http://dev.mysql.com/doc/plusplus/en/index.html
>
> As a user, maybe - but as a developer I wouldn't touch MySQL++ with
> a ten foot pole.
>
> I'm the current maintainer of mysqlcppapi, which was forked from
MySQL++
> to fix the most glaring errors, but I'd even hesitate to recommend
> that! It is a vast improvement, but is still far from the quality I'd
> expect from a Boost library.
>
> jon
>

[Brian Braatz] Please allow me to clarify; I am referring to the
INTERFACE presented to the programmer. I had pretty good success taking
people from a MS ADO world and using MYSql++.

>From your web page:
"
Here are the major changes:

All objects are classes with constructors and destructors, so all data
is initialized.
Reference-counting is used to allow sharing of the various object
instances and underlying connections, avoiding segfaults or complicated
memory management.
All classes are in the mysqlcppapi namespace
There is now no public member data.
Many methods have been un-inlined, allowing a much clearer file
structure.
The 'custom' and stored query interfaces have been removed because they
made excessive use of preprocessor macros and perl-generated code.
Exceptions are no longer optional - they are part of the design.
The fields classes have been completely replaced.
"
http://mysqlcppapi.sourceforge.net/

Excellent. The work you have done, I would agree with. What I am talking
about is the basic interface of being able to do:

(from the mysql examples)

#include <iostream>
#include <iomanip>
#include <sqlplus.hh>
  
int main() {
  Connection con("mysql_cpp_data");
  // The full format for the Connection constructor is
  // Connection(cchar *db, cchar *host="",
  // cchar *user="", cchar *passwd="")
  // You may need to specify some of them if the database is not on
  // the local machine or you database username is not the same as your
  // login name, etc..
  
  Query query = con.query();
  // This creates a query object that is bound to con.
  
  query << "select * from stock";
  // You can write to the query object like you would any other ostrem
  
  Result res = query.store();
  // Query::store() executes the query and returns the results
  
  cout << "Query: " << query.preview() << endl;
  // Query::preview() simply returns a string with the current query
  // string in it.
  
  cout << "Records Found: " << res.size() << endl << endl;
  
  Row row;
  cout.setf(ios::left);
  cout << setw(17) << "Item"
       << setw(4) << "Num"
       << setw(7) << "Weight"
       << setw(7) << "Price"
       << "Date" << endl
       << endl;
  
  Result::iterator i;
  // The Result class has a read-only Random Access Iterator
  for (i = res.begin(); i != res.end(); i++) {
    row = *i;
    cout << setw(17) << row[0]
         << setw(4) << row[1]
         << setw(7) << row["weight"]
      // you can use either the index number or column name when
      // retrieving the colume data as demonstrated above.
         << setw(7) << row[3]
         << row[4] << endl;
  }
  return 0;
}

I like the fact that I have a table\recordset style structure (Result)
I like the fact that it is iterator friendly
I like the fact that the code above would be understandable from a
person coming from an MS ADO world (which would lead to more adoption of
the library)


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk