From 498e1d44740e4d1d98f1c0bc719a7b78985b22b6 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Fri, 17 Apr 2015 22:57:34 -0700 Subject: [PATCH] Add support for configuring MySQL port --- redash/query_runner/mysql.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/redash/query_runner/mysql.py b/redash/query_runner/mysql.py index 1623bef945..93623a3059 100644 --- a/redash/query_runner/mysql.py +++ b/redash/query_runner/mysql.py @@ -27,7 +27,10 @@ def configuration_schema(cls): 'db': { 'type': 'string', 'title': 'Database name' - } + }, + "port": { + "type": "number" + }, }, 'required': ['db'] } @@ -82,10 +85,11 @@ def get_schema(self): def run_query(self, query): import MySQLdb - connection = MySQLdb.connect(self.configuration.get('host', ''), - self.configuration.get('user', ''), - self.configuration.get('passwd', ''), - self.configuration['db'], + connection = MySQLdb.connect(host=self.configuration.get('host', ''), + user=self.configuration.get('user', ''), + passwd=self.configuration.get('passwd', ''), + db=self.configuration['db'], + port=self.configuration.get('port', 3306), charset='utf8', use_unicode=True) cursor = connection.cursor() @@ -129,4 +133,4 @@ def run_query(self, query): return json_data, error -register(Mysql) \ No newline at end of file +register(Mysql)