Merge pull request #1910 from getredash/patches

Fix: PostgreSQL passwords with spaces were not supported.
This commit is contained in:
Arik Fraimovich
2017-08-06 20:38:16 +03:00
committed by GitHub
2 changed files with 8 additions and 11 deletions

View File

@@ -91,6 +91,7 @@
- When setting rearm on a new alert, it wasn't persisted.
- Salesforce: sandbox parameter should be optional. @msnider
- Alert page wasn't properly linked from alerts list. @alison985
- PostgreSQL passwords with spaces were not supported. (#1056)
## v1.0.3 - 2017-04-18

View File

@@ -1,7 +1,6 @@
import json
import logging
import select
import sys
import psycopg2
@@ -81,15 +80,6 @@ class PostgreSQL(BaseSQLQueryRunner):
def type(cls):
return "pg"
def __init__(self, configuration):
super(PostgreSQL, self).__init__(configuration)
values = []
for k, v in self.configuration.iteritems():
values.append("{}={}".format(k, v))
self.connection_string = " ".join(values)
def _get_definitions(self, schema, query):
results, error = self.run_query(query, None)
@@ -136,7 +126,13 @@ class PostgreSQL(BaseSQLQueryRunner):
return schema.values()
def run_query(self, query, user):
connection = psycopg2.connect(self.connection_string, async=True)
connection = psycopg2.connect(user=self.configuration.get('user'),
password=self.configuration.get('password'),
host=self.configuration.get('host'),
port=self.configuration.get('port'),
dbname=self.configuration.get('dbname'),
async=True)
_wait(connection, timeout=10)
cursor = connection.cursor()