On 3-apr-11, at 15:59, Christian Manning wrote:

On 03/04/2011 14:42, Piotr Szturmaj wrote:
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? :)

I was going to reply with a link to your work but you beat me to it.
I think it's a great design and incorporating it or something similar into the API may be the way to go.

Indeed ddb looks really nice (I hadn't looked at it yet), given it though, I have to agree that just adding mySQL support is too little and not really innovative for 3 months work...

Fawzi

Reply via email to