39 lines
740 B
D
39 lines
740 B
D
module pgdb;
|
|
|
|
import arsd.postgres;
|
|
import std.stdio;
|
|
|
|
alias pgsql = PG.getConnection;
|
|
|
|
class PG : PostgreSql {
|
|
private:
|
|
static PG _pgsql;
|
|
this(string config) {
|
|
super(config);
|
|
}
|
|
public:
|
|
@property static PG getConnection(string config = null) {
|
|
if (this._pgsql is null) {
|
|
try {
|
|
this._pgsql = new PG(config);
|
|
} catch (Exception e) {
|
|
throw new Exception(e.msg);
|
|
}
|
|
}
|
|
|
|
return this._pgsql;
|
|
}
|
|
|
|
PostgresResult sql(T...)(string query, T t) {
|
|
return cast(PostgresResult)this.query(query, t);
|
|
}
|
|
|
|
void commit() {
|
|
this.query("COMMIT");
|
|
}
|
|
|
|
void rollback() {
|
|
this.query("ROLLBACK");
|
|
}
|
|
}
|