mysql binding/wrapper?

Adam D. Ruppe destructionator at gmail.com
Sat Apr 28 08:54:49 PDT 2012


On Saturday, 28 April 2012 at 15:30:13 UTC, simendsjo wrote:
> https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff/blob/master/mysql.d

That's mine. I use it all the time; nothing super fancy, but
it gets the job done for me.

I didn't really document it... but the basic usage is simple:

auto mysql = new MySql("hostname, "username", "password", 
"database_name");

int userId = getMyUserId();

foreach(line; mysql.query("SELECT id, name FROM something WHERE 
user_id = ?", userId)) {
     line["id"]   == line[0]
     line["name"] == line[1]
}


The columns are returned as strings. The query returns a simple
range, so you can also check .empty, get .front, etc.


More information about the Digitalmars-d-learn mailing list