tag:support.appharbor.com,2010-11-23:/discussions/problems/64890-changing-mysql-connection-stringAppHarbor: Discussion 2014-09-23T03:24:07Ztag:support.appharbor.com,2010-11-23:Comment/346618162014-09-22T01:45:02Z2014-09-22T01:45:02ZChanging mysql connection string <div><p>Hi,</p>
<p>You can't do that through the Sequelizer add-on, but it's
straightforward to do in code and then initialize your MySQL client
with that instead. Here's some example code that shoudl work if you
wanted to set the CharSet and SSL mode connection string
parameters:</p>
<pre>
<code>public void Foo()
{
string databaseConnectionString = ConfigurationManager.ConnectionStrings["default"].ConnectionString;
databaseConnectionString = InjectIfMissing(databaseConnectionString, "CharSet", "utf8");
databaseConnectionString = InjectIfMissing(databaseConnectionString, "SSL Mode", "Required");
}
private static string InjectIfMissing(string input, string key, string value)
{
if (!input.Split(';').Any(x => x.Trim().StartsWith(string.Format("{0}=", key))))
{
return string.Concat(input, string.Format("; {0}={1}", key, value));
}
return input;
}</code>
</pre>
<p>Let me know if that doesn't help!</p>
<p>Best,<br>
Rune</p></div>runetag:support.appharbor.com,2010-11-23:Comment/346618162014-09-22T10:05:26Z2014-09-22T10:05:26ZChanging mysql connection string <div><p>Thanks Rune</p>
<p>I was hoping to avoid changing the strings in code!</p>
<p>Thanks again</p></div>antonydenyertag:support.appharbor.com,2010-11-23:Comment/346618162014-09-23T03:24:07Z2014-09-23T03:24:07ZChanging mysql connection string <div><p>I agree that it would be neater if you could inject this on the
Sequelizer page or apply another sort of transformation to
accomplish this. I hope this works out until we have more a more
customizable option available.</p>
<p>Best,<br>
Rune</p></div>rune