import std.database.sql.*
main(): Unit {
// Obtains the registered driver.
let drv = DriverManager.getDriver("opengauss") ?? return
// Sets options for opening the data source.
let opts = [
("cachePrepStmts", "true"),
("prepStmtCacheSize", "250"),
("prepStmtCacheSqlLimit", "2048")
]
// Opens the data source using the connection path and options.
let ds = drv.open("opengauss://testuser:testpwd@localhost:5432/testdb", opts)
// Sets connection options.
ds.setOption(SqlOption.SSLMode, SqlOption.SSLModeVerifyCA)
ds.setOption(SqlOption.SSLCA, "ca.crt")
ds.setOption(SqlOption.SSLCert, "server.crt")
ds.setOption(SqlOption.SSLKey, "server.key")
ds.setOption(SqlOption.SSLKeyPassword, "key_password")
ds.setOption(SqlOption.TlsVersion, "TLSv1.2,TLSv1.3")
// Returns an available connection.
ds.connect()
}