On 8/2/2011 7:39 PM, Adam Ruppe wrote:
Johann MacDonagh wrote:
Perhaps we should start taking a look at it,
making it "Phobos-like", and create bindings for a set of databases.

In my collection, I have (kinda crappy) implementations of my
interface for mysql, postgres, sqlite and most recently ODBC.

Since they all use C libs though, I'm not really completely sure
on if they are license compatible with phobos. And, of course, I'm
happy with a minimal set of features; I'm happy enough with strings
since it's better than PHP, so mission accomplished.

(I also have a lot of other code. Check out the readme in my github
for a listing of many of them.)

Sounds like a good starting point. I've also written some code for allowing "LINQ" style queries in D. You'd be able to do something like:

auto x = new SqliteConnection("mydata.db");

foreach(y; x.MyTable.where("someField > 10"))
{
    // y is a wrapper around Variant[string] with some opDispatch magic
    writeln(to!string(y.MyField));
    writeln(to!int(y.SomeOtherField));
}

There were other things you could chain, such as:

x.MyTable.startAt(20).limit(10).where("blah").select("somefield", "sometingElse");

You'd also be able to do something like

x.MyTable.select!MyStruct();

which would pull field names out of struct fields, and return a range of structs rather than something that has to go through the Variant[string] stuff.

It's just a prototype for now, I have a working POC for sqlite3 (however it doesn't support the where clause ;) ), but it might be something useful for quickly prototyping code that deals with databases.

Would you mind if I take some of your ideas and come up with a proposal for the D community to talk about? Then we can discuss licensing issues with various databases systems.

Reply via email to