dpq 0.0.2

A postgresql (libpq, pq) library aiming to be simple to use


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:

dpq - A D PostgreSQL library

dpq wraps the libpq library and aims to provide a simple and modern way to access PostgreSQL in the D programming language.

Current features:

  • Opening a connection using a connection string
  • Queries
  • Fetching the results of queries in binary format
  • Looping through the said results
  • Exceptions on query errors

## Planned features

  • Object-relational mapping
  • Automatic schema creating from objects
  • Connection pooling

## Documentation

There is no docs yet, in the future, they should be written into the source code itself.

Some notes:

  • If a wrong type is specified while fetching a column, the results are undefined. Most likely just garbage

Licence

MIT, read LICENSE.txt

Very simple example code

import std.stdio;
import dpq.connection;
import dpq.query;

void main()
{
	auto conn = Connection("host=somehost dbname=testdb user=testuser password='VerySecureTestPassword'");
	// One-line query execution, the same could be done with Connection.exec(string command)
	Query("CREATE TABLE IF NOT EXISTS test (id SERIAL, txt TEXT)").run();
	
	// Last connection will be used if none is specified as the first param to Query()
	q = Query("SELECT id, txt FROM test WHERE id = $1 OR id = $2");
	// Params could also be added with the << operator
	// r << 4 << 1;
	r = q.run(4, 1);
	foreach (row; r)
		writeln("row['txt'] is: ", row["txt"].as!string);

    // Connection does not have to be closed, the destructor will take care of that.
}

Authors:
  • Irenej
Dependencies:
derelict-pq
Versions:
0.11.6 2022-Jun-04
0.11.5 2021-Jun-25
0.11.4 2020-Sep-30
0.11.3 2020-Sep-05
0.11.2 2020-Aug-25
Show all 56 versions
Download Stats:
  • 0 downloads today

  • 2 downloads this week

  • 3 downloads this month

  • 3851 downloads total

Score:
1.4
Short URL:
dpq.dub.pm