Description

PostgreSQL support for Vibe.d

Package Information

Version 0.2.20 (2016-Dec-16)
Repository https://github.com/denizzzka/vibe.d.db.postgresql
License MIT
Copyright Copyright © 2016
Authors Denis Feklushkin <denis.feklushkin@gmail.com>
Registered by Denis F
Sub packages
vibe-d-postgresql:example
Dependencies

vibe-d:core

dpq2

Installation

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

dub.json
dub.sdl

Readme

PostgreSQL support for Vibe.d

Example:

module vibe.db.postgresql.example;

import vibe.d;
import vibe.db.postgresql;

shared PostgresClient client;

void test()
{
    auto conn = client.lockConnection();
    immutable result = conn.execStatement(
        "SELECT 123 as first_num, 567 as second_num, 'abc'::text as third_text "~
        "UNION ALL "~
        "SELECT 890, 233, 'fgh'::text as third_text",
        ValueFormat.BINARY
    );
    delete conn;

    assert(result[0]["second_num"].as!PGinteger == 567);
    assert(result[1]["third_text"].as!PGtext == "fgh");

    foreach (val; rangify(result[0]))
        logInfo("Found entry: %s", val.as!Bson.toJson);
}

shared static this()
{
    // params: conninfo string, number of simultaneous connections
    client = new shared PostgresClient("dbname=postgres user=postgres", 4);

    test();
}

Output:

Found entry: 123
Found entry: 567
Found entry: "abc"

Available versions

0.2.20 0.2.19 0.2.18 0.2.17 0.2.16 0.2.15 0.2.14 0.2.13 0.2.12 0.2.11 0.2.10 0.2.9 0.2.8 0.2.7 0.2.6 0.2.5 0.2.4 0.2.3 0.2.2 0.2.1 0.2.0 0.1.1 0.1.0 0.0.2 0.0.1 ~master ~try_to_create_new_pool_with_lockedconn_class