On Tue, Oct 11, 2011 at 12:40:52PM -0500, Andrei Alexandrescu wrote:
>     auto db = connect("
>         engine = mysql;
>         user = john;
>         password = doe;
>         port = 6900;
>     ");

Why is that a string? I'd just use different constructors for
different engines, and let them work however they work for the target.


Here's what a simple program looks like with my database code:

import arsd.mysql;

void main() {
        auto db = new MySql("localhost", "user", "password", "database");
        scope(exit) delete db;
        foreach(line; db.query("do whatever")) {
                writeln(line[0], line[1]);
        }
}

OR

import arsd.postgres;

void main() {
        auto db = new PostgreSql("dbname = test");
        scope(exit) delete db;
        foreach(line; db.query("do whatever")) {
                writeln(line[0], line[1]);
        }
}


OR

import arsd.sqlite;

void main() {
        auto db = new Sqlite("my-database.db");
        scope(exit) delete db;
        foreach(line; db.query("do whatever")) {
                writeln(line[0], line[1]);
        }
}





The biggest downside might be that the databases are
classes, so you either scope them or garbage collect them..
but that doesn't really bother me.

Reply via email to