Add redshift (and DigitalOcean Managed DB) compatibility and start using a string building to create the sql connection string
This commit is contained in:
parent
a4b914d576
commit
d9f8e9a80e
4 changed files with 28 additions and 3 deletions
|
@ -37,7 +37,8 @@ namespace Geekbot.net.Database
|
|||
Username = _runParameters.DbUser,
|
||||
Password = _runParameters.DbPassword,
|
||||
RequireSsl = _runParameters.DbSsl,
|
||||
TrustServerCertificate = _runParameters.DbTrustCert
|
||||
TrustServerCertificate = _runParameters.DbTrustCert,
|
||||
RedshiftCompatibility = _runParameters.DbRedshiftCompatibility
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace Geekbot.net.Database
|
||||
using System.Text;
|
||||
|
||||
namespace Geekbot.net.Database
|
||||
{
|
||||
public class SqlConnectionString
|
||||
{
|
||||
|
@ -9,11 +11,29 @@
|
|||
public string Password { get; set; }
|
||||
public bool RequireSsl { get; set; }
|
||||
public bool TrustServerCertificate { get; set; }
|
||||
public bool RedshiftCompatibility { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("Application Name=Geekbot;");
|
||||
|
||||
sb.Append($"Host={Host};");
|
||||
sb.Append($"Port={Port};");
|
||||
sb.Append($"Database={Database};");
|
||||
sb.Append($"Username={Username};");
|
||||
sb.Append($"Password={Password};");
|
||||
|
||||
var sslMode = RequireSsl ? "Require" : "Prefer";
|
||||
return $"ApplicationName=Geekbot;Server={Host};Port={Port};Database={Database};Uid={Username};Pwd={Password};SSLMode={sslMode};TrustServerCertificate={TrustServerCertificate.ToString()};";
|
||||
sb.Append($"SSL Mode={sslMode};");
|
||||
sb.Append($"Trust Server Certificate={TrustServerCertificate.ToString()};");
|
||||
|
||||
if (RedshiftCompatibility)
|
||||
{
|
||||
sb.Append("Server Compatibility Mode=Redshift");
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue