mysql-lited 0.1.0

Lightweight native MySQL protocol implementation


To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

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[0].get!int);
    if (index == 5)
        return false; // optionally return false to discard remaining results
});

todo

  • fix a few remaining allocations
  • add proper unit tests
  • implement COMSTMTSENDLONGDATA, and a single parameter binding interface
  • make vibe-d dependency optional
  • optional higher-level interfaces (i.e. serialize row into struct or associative array)
  • optional throttled batch inserter
Authors:
  • Márcio Martins
Dependencies:
vibe-d
Versions:
0.4.7 2019-Feb-01
0.4.6 2018-Nov-07
0.4.5 2018-Sep-07
0.4.4 2018-Aug-22
0.4.3 2018-Jul-30
Show all 65 versions
Download Stats:
  • 1 downloads today

  • 4 downloads this week

  • 4 downloads this month

  • 4424 downloads total

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