mysql-lited 0.1.5

Lightweight native MySQL protocol implementation


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

mysql-lited

A lightweight native mysql driver written in D

The goal is a native driver that re-uses the same buffers and the stack as much as possible, avoiding unnecessary work for the garbage collector

notes

  • supports all MySQL types with conversion from/to D types
  • results are retrieved through a flexible callback interface
  • socket type is a template parameter - currently only a vibesocket is implemented - more to come
  • only the binary protocol is supported

example

conn.connect("host=sql.moo.com;user=root;pwd=god;db=mew");
//conn.use("mewmew");

// re-usable prepared statements
auto upd = conn.prepare("update manytypes set int_ = ?, timestamp_ = ?, blob_ = ?");
foreach(int_; 0..100) {
    conn.execute(upd, int_, Clock.currTime, sha1Of(int_));
}

// one-shot query
conn.execute("select * from manytypes where id > ?", 13, (size_t index /*optional*/, MySQLHeader header /*optional*/, MySQLRow row) {
    writeln(header[0].name, ": ", row.int_.get!int);
    if (index == 5)
        return false; // optionally return false to discard remaining results
});

// structured row
struct Point {
    int x, y, z;
};

conn.execute("select x, y, z from points where x > y and y > z", (MySQLRow row) {
    auto p = row.structured!Point; // default is strict mode, where a missing or null field in the row will throw
    // auto p = row.structured!(Point, Strict.no); // missing or null will just be ignored
    writeln(p);
});

todo

  • add proper unit tests
  • implement COMSTMTSENDLONGDATA, and a single parameter binding interface
  • make vibe-d dependency optional
Authors:
  • Márcio Martins
Dependencies:
vibe-d
Versions:
0.4.9 2019-Aug-01
0.4.8 2019-Apr-10
0.4.7 2019-Feb-01
0.4.6 2018-Nov-07
0.4.5 2018-Sep-07
Show all 68 versions
Download Stats:
  • 0 downloads today

  • 1 downloads this week

  • 3 downloads this month

  • 4761 downloads total

Score:
1.8
Short URL:
mysql-lited.dub.pm