Support Python3 for PostgresMetadataExtractor
import logging
+import six
from collections import namedtuple
from pyhocon import ConfigFactory, ConfigTree # noqa: F401
@@ -60,8 +61,11 @@ class PostgresMetadataExtractor(Extractor):
else:
cluster_source = "'{}'".format(self._cluster)
- self._database = conf.get_string(PostgresMetadataExtractor.DATABASE_KEY,
- default='postgres').encode('utf-8', 'ignore')
+ database = conf.get_string(PostgresMetadataExtractor.DATABASE_KEY, default='postgres')
+ if six.PY2 and isinstance(database, six.text_type):
+ database = database.encode('utf-8', 'ignore')
+
+ self._database = database
self.sql_stmt = PostgresMetadataExtractor.SQL_STATEMENT.format(
where_clause_suffix=conf.get_string(PostgresMetadataExtractor.WHERE_CLAUSE_SUFFIX_KEY),
