vibe-d-postgresql 1.0.0-alpha.2

PostgreSQL support for Vibe.d


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

dub.json
dub.sdl

PostgreSQL support for Vibe.d

Example:

module vibe.db.postgresql.example;

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

PostgresClient client;

void test()
{
    auto conn = client.lockConnection();
    scope(exit) delete conn;

    try
    {
        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
        );

        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);

        import core.memory;
        GC.collect();
    }
    catch(ConnectionException e)
    {
        conn.resetStart();
        logWarn(e.msg);
    }
    catch(Exception e)
    {
        logWarn(e.msg);
    }
}

static this()
{
    // params: conninfo string, maximum number of connections in
    // the connection pool
    client = new PostgresClient("dbname=postgres user=postgres", 4);

    test();
}

Output:

Found entry: 123
Found entry: 567
Found entry: "abc"
Authors:
Denis Feklushkin <denis.feklushkin@gmail.com>
Sub packages:
vibe-d-postgresql:example
Dependencies:
vibe-d:core, dpq2
Versions:
1.0.0-alpha.2 2018-Feb-08
1.0.0-alpha.1 2018-Feb-08
0.3.0-beta.4 2018-Jan-08
0.3.0-beta.3 2017-Oct-03
0.3.0-beta.2 2017-Oct-03
Show all 37 versions
Download Stats:
  • 3 downloads today

  • 36 downloads this week

  • 101 downloads this month

  • 3166 downloads total