dstddb 0.0.4

A D standard database proposal and 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:

dstddb

A proposed standard database client interface and implementation for the D Language

Status: early stage project - unstable and minimally tested

Available in DUB, the D package registry

Roadmap Highlights

  • A database and driver neutral interface specification
  • Reference counted value objects provide ease of use
  • Templated implementations for Phobos compatibility
  • Support for direct and polymorphic interfaces
  • A range interface for query result sets
  • Support a for fluent style interface
  • URL style connection strings
  • Reference implementations so far: mysql, sqlite, oracle, and ODBC
  • Support for allocators
  • Support for runtime driver registration
  • Input variable binding support
  • Array input/output binding support
  • Connection pooling

Examples

simple query
import std.database.mysql;
auto db = createDatabase("mysql://database");
db.query("insert into table('name',123)");
expanded classic style select
import std.database.mysql;
auto db = createDatabase("mysql://127.0.0.1/test");
auto con = db.connection();
auto stmt = con.statement("select * from table");
auto rowSet = stmt.query();
auto range = stmt[];
foreach (row; range) {
    for(size_t col = 0; col != row.columns; ++col) write(rowr[col]), " ");
    writeln();
}

fluent style select
import std.database.sqlite;
createDatabase("file:///demo.sqlite")
.connection()
    .query("select * from t1")
    .writeResult();
field access
```D
import std.database.sqlite;
auto db = createDatabase("file:///testdb");
auto rowSet = db.connection().query("select name,score from score");
foreach (r; rowSet) {
    writeln(r[0].as!string,",",r[1].as!int);
}


#### select with input binding

import std.database.sqlite; int minScore = 50; createDatabase("file:///demo.sqlite") .connection()

.query("select * from t1 where score >= ?", minScore)
.writeResult();
```

insert with input binding
```D
import std.database;
auto db = createDatabase("mydb");
auto con = db.connection();
auto stmt = con.statement("insert into table values(?,?)");
stmt.query("a",1);
stmt.query("b",2);
stmt.query("c",3);
```

poly database setup (driver registration)
```D
import std.database.poly;
Database.register!(std.database.sqlite.Database)();
Database.register!(std.database.mysql.Database)();
Database.register!(std.database.oracle.Database)();
auto db = createDatabase("mydb");
```

Notes

  • The reference implementations use logging (std.experimental.logger). To hide the info logging, add this line to your package.json file: "versions": ["StdLoggerDisableInfo"].

Status

WIP

| Feature                         | sqlite | mysql  | oracle | postgres | odbc  | poly  |
| :---------------------------    | :----- | :----- | :----- | :------  | :---- | :---- |
| command only execution          | y      | y      | y      | y        | y     |       |
| select no-bind with results     | y      | y      | y      | y        | y     |       |
| input binding (string/int only) | y      | y      | y      | y        |       |       |
| native column type buffers      |        | y      |        |          |       |       |

Authors:
  • Erik Smith
Dependencies:
none
Versions:
0.0.13 2018-Feb-25
0.0.12 2018-Feb-24
0.0.11 2018-Feb-24
0.0.10 2016-Jun-23
0.0.9 2016-May-06
Show all 12 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 170 downloads total

Score:
1.6
Short URL:
dstddb.dub.pm