Fawzi Mohamed wrote:
Well the comments in there are what is important, and will need to be
specified better IMHO.

The most important part in my opinion is how one chooses to represent a
record.
A big design choice is if the various fields are defined at compile time
or at runtime.
Also how does one add special behavior to a record? Do you use a
subclasses of the generic record type (as ruby does for example)?

I'm working on DB API for few months in my spare time. I'm delayed that much by my other projects. Please take a look at my ideas:

http://github.com/pszturmaj/ddb

Documentation:
http://pszturmaj.github.com/ddb/db.html
http://pszturmaj.github.com/ddb/postgres.html

In my code, row is represented using struct DBRow!(Specs...). Fields may be known at compile time or not. DBRow besides base types, may be instantiated using structs, tuples or arrays. Untyped row (no compile time information) is DBRow!(Variant[]).

Typed rows are very useful, for example you don't need to manually cast columns to your types, it's done automatically, e.g.:

auto cmd = new PGCommand(conn, "SELECT typname, typlen FROM pg_type");
auto result = cmd.executeQuery!(string, "typName", int, "len");

foreach (row; result)
{
    // here, row DBRow subtypes
    // a Tuple!(string, "typName", int, "len")
    writeln(row.typName, ", ", row.len);
}

What do you think? :)

Reply via email to