Add basic PGSQL connection
This commit is contained in:
27
source/db/pgsql.d
Normal file
27
source/db/pgsql.d
Normal file
@@ -0,0 +1,27 @@
|
||||
module db.pgsql;
|
||||
|
||||
import db.db;
|
||||
|
||||
import ddbc.core;
|
||||
import ddbc.common;
|
||||
|
||||
class PostgresDB : DB {
|
||||
shared this(Args...)(auto ref Args args) {
|
||||
super(args);
|
||||
}
|
||||
|
||||
protected override DataSource getDataSource() {
|
||||
import ddbc.drivers.pgsqlddbc;
|
||||
|
||||
Driver driver = new PGSQLDriver();
|
||||
string url;
|
||||
string[string] params;
|
||||
|
||||
with (this.m_settings) {
|
||||
url = PGSQLDriver.generateUrl(host, port, dbname);
|
||||
params = PGSQLDriver.setUserAndPassword(username, password);
|
||||
}
|
||||
|
||||
return new ConnectionPoolDataSourceImpl(driver, url, params);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user