daster/source/pgdb.d
Alexander Zhirov 815b5a6b6a v0.0.1
Разработка:
- БД скрипт с начальными данными
- вывод списка номеров телефонов по группам
2023-05-31 02:04:03 +03:00

38 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");
}
}