Connection

Represents the PostgreSQL connection and allows executing queries on it.

struct Connection {}

Constructors

this
this(string connString)

Connection constructor

Members

Aliases

ConnectionPtr
alias ConnectionPtr = SmartPointer!(PGconn*, PQfinish)
Undocumented in source.

Functions

allResults
Result[] allResults()
Undocumented in source. Be warned that the author may not have intended to support it.
close
void close()

Close the connection manually

ensureSchema
void ensureSchema(bool createType)

Generates and runs the DDL from the given structures

exec
Result exec(string command)

// FIXME: BROKEN ATM Executes the given string directly

execParams
Result execParams(string command, T params)

Executes the given string with given params

execParams
Result execParams(string command, Value[] params, bool async)

ditto, but taking an array of params, instead of variadic template

execPrepared
Result execPrepared(string name, Value[] params)
Undocumented in source. Be warned that the author may not have intended to support it.
execPrepared
Result execPrepared(string name, T params)
Undocumented in source. Be warned that the author may not have intended to support it.
find
T[] find(string filter, U vals)

Returns an array of the specified type, filtered with the given filter and params

findOne
Nullable!T findOne(U id)

Returns the requested structure or a Nullable null value if no rows are returned

findOne
Nullable!T findOne(string filter, U vals)

Returns the requested structure, searches by the specified filter with given params

findOneBy
Nullable!T findOneBy(string col, U val)

Returns the requestes structure, searches by the given column name with the given value If not rows are returned, a Nullable null value is returned

insert
bool insert(T val, bool async)
Undocumented in source. Be warned that the author may not have intended to support it.
insertAsync
void insertAsync(T val)
Undocumented in source. Be warned that the author may not have intended to support it.
isBusy
bool isBusy()
Undocumented in source. Be warned that the author may not have intended to support it.
lastResult
Result lastResult()
Undocumented in source. Be warned that the author may not have intended to support it.
nextResult
Result nextResult()

Blocks until a result is read, then returns it

opIndex
PreparedStatement opIndex(string name)
Undocumented in source. Be warned that the author may not have intended to support it.
prepare
Result prepare(string name, string command, T paramTypes)
Undocumented in source. Be warned that the author may not have intended to support it.
prepared
PreparedStatement prepared(string name)
Undocumented in source. Be warned that the author may not have intended to support it.
remove
int remove(U id)
Undocumented in source. Be warned that the author may not have intended to support it.
remove
int remove(string filter, U vals)
Undocumented in source. Be warned that the author may not have intended to support it.
removeAsync
bool removeAsync(U id)
Undocumented in source. Be warned that the author may not have intended to support it.
removeAsync
bool removeAsync(string filter, U vals)
Undocumented in source. Be warned that the author may not have intended to support it.
send
bool send(string command)

ditto, async

sendParams
void sendParams(string command, T params)
Undocumented in source. Be warned that the author may not have intended to support it.
sendParams
void sendParams(string command, Value[] params)

ditto, async

sendPrepared
bool sendPrepared(string name, Value[] params)
Undocumented in source. Be warned that the author may not have intended to support it.
sendPrepared
bool sendPrepared(string name, T params)
Undocumented in source. Be warned that the author may not have intended to support it.
update
int update(string filter, string update, U vals)
Undocumented in source. Be warned that the author may not have intended to support it.
update
int update(U id, Value[string] updates, bool async)
Undocumented in source. Be warned that the author may not have intended to support it.
update
int update(U id, T updates, bool async)
Undocumented in source. Be warned that the author may not have intended to support it.
updateAsync
void updateAsync(string filter, string update, U vals)
Undocumented in source. Be warned that the author may not have intended to support it.
updateAsync
void updateAsync(U id, Value[string] updates)
Undocumented in source. Be warned that the author may not have intended to support it.
updateAsync
void updateAsync(U id, T updates)
Undocumented in source. Be warned that the author may not have intended to support it.

Properties

db
const(string) db [@property getter]

Returns the name of the database currently selected

errorMessage
string errorMessage [@property getter]

Returns the last error message

host
const(string) host [@property getter]

ditto, but host

password
const(string) password [@property getter]

ditto, but password

port
const(ushort) port [@property getter]

ditto, but port

status
const(ConnStatusType) status [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
user
const(string) user [@property getter]

Returns the name of the current user

Examples

auto conn = Connection("host=localhost dbname=testdb user=testuser");
//conn.exec ...

Meta