Merge pull request #406 from stanhu/add-mysql-port

Add support for configuring MySQL port
This commit is contained in:
Arik Fraimovich 2015-04-18 16:14:26 +03:00
commit 8a35dcedfa

View File

@ -27,7 +27,10 @@ class Mysql(BaseQueryRunner):
'db': { 'db': {
'type': 'string', 'type': 'string',
'title': 'Database name' 'title': 'Database name'
} },
"port": {
"type": "number"
},
}, },
'required': ['db'] 'required': ['db']
} }
@ -82,10 +85,11 @@ class Mysql(BaseQueryRunner):
def run_query(self, query): def run_query(self, query):
import MySQLdb import MySQLdb
connection = MySQLdb.connect(self.configuration.get('host', ''), connection = MySQLdb.connect(host=self.configuration.get('host', ''),
self.configuration.get('user', ''), user=self.configuration.get('user', ''),
self.configuration.get('passwd', ''), passwd=self.configuration.get('passwd', ''),
self.configuration['db'], db=self.configuration['db'],
port=self.configuration.get('port', 3306),
charset='utf8', use_unicode=True) charset='utf8', use_unicode=True)
cursor = connection.cursor() cursor = connection.cursor()