hunt-database ~master

A database client for D Programming Language.

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

This package provides sub packages which can be used individually:

hunt-database:base - DB client abstruct library for D Programming Language.

hunt-database:mysql - MySQL client for D Programming Language.

hunt-database:postgresql - PostgreSQL client for D Programming Language.

Build Status


Database abstraction layer for D programing language, support PostgreSQL / MySQL / SQLite.


import std.stdio;

import hunt.database;

void main()
    writeln("run database MySQL demo.");

    auto db = new Database("mysql://root:123456@localhost:3306/test?charset=utf8mb4");

    int result = db.execute(`INSERT INTO user(username) VALUES("test")`);

    foreach(row; db.query("SELECT * FROM user LIMIT 10"))


Use DatabaseOption to instantiate a Database object

auto options = new DatabaseOption("mysql://root:123456@localhost:3306/test");

auto db = new Database(options);

db.execute("SET NAMES utf8");


  • int Database.execute(string sql) Return number of execute result.
int result = db.execute('INSERT INTO user(username) VALUES("Brian")');
// if execute error ,db will throw an DatabaseException
  • ResultSet Database.query(sql) Return ResultSet object for query(SELECT).
ResultSet rs = db.query("SELECT * FROM user LIMIT 10");
  • Statement Database.prepare(sql) Create a prepared Statement object.
Statement stmt = db.prepare("SELECT * FROM user where username = :username and age = :age LIMIT 10");
  • Statement.setParameter(param, value) : bind param's value to :param for sql.
stmt.setParameter("username", "viile");
stmt.setParameter("age", 18);
  • ResultSet Statement.query() Return ResultSet
ResultSet rs = stmt.query();
foreach(row; rs)
  • Row Statement.fetch() Return Row
Row row = stmt.fetch();
  • int Statement.execute() : return execute status for prepared Statement object.
int result = stmt.execute();
  • Statement.lastInsertId() : Statement.execute() for insert sql, return lastInsertId.
Sub packages:
hunt-database:base, hunt-database:mysql, hunt-database:postgresql
hunt-database:base, hunt-database:postgresql, hunt-database:mysql
1.3.1 2019-Jul-07
1.3.0 2019-Jun-04
1.2.0 2019-May-05
1.1.5 2019-Mar-28
1.0.5 2019-Jan-14
Show all 8 versions
Download Stats:
  • 15 downloads today

  • 66 downloads this week

  • 267 downloads this month

  • 3074 downloads total

Short URL: