Skip to content

Commit

Permalink
Add new conn options in MySQL (#6538)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianoapj authored Oct 19, 2023
1 parent 7b03e60 commit 8bb1767
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions redash/query_runner/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,38 @@ def configuration_schema(cls):
"connect_timeout": {"type": "number", "default": 60, "title": "Connection Timeout"},
"charset": {"type": "string", "default": "utf8"},
"use_unicode": {"type": "boolean", "default": True},
"autocommit": {"type": "boolean", "default": False},
},
"order": ["host", "port", "user", "passwd", "db", "connect_timeout", "charset", "use_unicode"],
"order": [
"host",
"port",
"user",
"passwd",
"db",
"connect_timeout",
"charset",
"use_unicode",
"autocommit",
],
"required": ["db"],
"secret": ["passwd"],
}

if show_ssl_settings:
schema["properties"].update(
{
"ssl_mode": {
"type": "string",
"title": "SSL Mode",
"default": "preferred",
"extendedEnum": [
{"value": "disabled", "name": "Disabled"},
{"value": "preferred", "name": "Preferred"},
{"value": "required", "name": "Required"},
{"value": "verify-ca", "name": "Verify CA"},
{"value": "verify-identity", "name": "Verify Identity"},
],
},
"use_ssl": {"type": "boolean", "title": "Use SSL"},
"ssl_cacert": {
"type": "string",
Expand Down Expand Up @@ -112,6 +135,7 @@ def _connection(self):
charset=self.configuration.get("charset", "utf8"),
use_unicode=self.configuration.get("use_unicode", True),
connect_timeout=self.configuration.get("connect_timeout", 60),
autocommit=self.configuration.get("autocommit", True),
)

ssl_options = self._get_ssl_parameters()
Expand Down Expand Up @@ -216,7 +240,7 @@ def _get_ssl_parameters(self):
ssl_params = {}

if self.configuration.get("use_ssl"):
config_map = {"ssl_cacert": "ca", "ssl_cert": "cert", "ssl_key": "key"}
config_map = {"ssl_mode": "preferred", "ssl_cacert": "ca", "ssl_cert": "cert", "ssl_key": "key"}
for key, cfg in config_map.items():
val = self.configuration.get(key)
if val:
Expand Down

0 comments on commit 8bb1767

Please sign in to comment.