Add basic PGSQL connection

This commit is contained in:
2024-01-28 21:48:03 -03:00
parent 8ee6cbefbd
commit 297786133d
4 changed files with 89 additions and 2 deletions

27
source/db/pgsql.d Normal file
View 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);
}
}