v0.0.1
Разработка: - БД скрипт с начальными данными - вывод списка номеров телефонов по группам
This commit is contained in:
parent
ca5259c638
commit
815b5a6b6a
34 changed files with 1229 additions and 49 deletions
38
source/pgdb.d
Normal file
38
source/pgdb.d
Normal file
|
@ -0,0 +1,38 @@
|
|||
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");
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue