March 15, 2017
> The retrieval of records is done via the execution of a (prepared) sql query, that returns a range object (PGResultSet), and the element of that range is the DBRow, in one of its form.
>
> So, basically, the elements are retrieved on demand while you popFront that range, leveraging what the PostgreSQL stream protocol provide.
>
> ---
> Paolo

Could you give an example when it's better to use DBRow and where to get data in structure?
March 16, 2017
On 2017-03-14 14:32, Suliman wrote:

> Does it work fine on Linux with x64 Postgres?

I've tested it on macOS and Linux 64bit. Works great.

-- 
/Jacob Carlborg
March 17, 2017
On 2017-03-15 15:08, Suliman wrote:

> Could you give an example when it's better to use DBRow and where to get
> data in structure?

Use PGCommand and call "executeQuery" to get back a result set that is iteratable:

auto query = "SELECT * FROM foos"
auto cmd = new PGCommand(connection, query);
auto resultSet = cmd.executeQuery!(string, int); // these types are the column types

foreach (row ; resultSet)
{
    auto name = row["name"];
    auto bar = row[1];
    // use the column name or index to get the value from a row
}

resultSet.close(); // the result set needs to be closed to be able to execute additional queries

You can also directly create structs out of the rows:

struct Foo
{
    string name;
    string bar;
}

auto resultSet = cmd.executeQuery!(typeof(Foo.tupleof));

foreach (row ; resultSet)
{
    auto foo = Foo(row[0 .. Foo.tupleof.length]);
    assert(foo.name == row["name"]);
}

executeQuery - for returning a set of rows
executeRow - for returning a single
executeNonQuery - for executing a query without any result

See the examples for more information [1].

[1] https://github.com/pszturmaj/ddb/blob/master/examples/basic.d

-- 
/Jacob Carlborg
March 19, 2017
On Wednesday, 15 March 2017 at 08:54:59 UTC, Paolo Invernizzi wrote:

> I'm curious: ddb does not support yet arbitrary precision numbers [1], does dpq support them?

Does Dlang supports them?
1 2
Next ›   Last »