Ver código fonte

HUE-8740 [editor] Improve Postgres SqlAlchemy integration

Romain 6 anos atrás
pai
commit
72e5733c3a

+ 3 - 2
desktop/libs/notebook/src/notebook/connectors/sqlalchemyapi.py

@@ -114,11 +114,12 @@ class SqlAlchemyApi(Api):
     engine = self._create_engine()
     connection = engine.connect()
     result = connection.execution_options(stream_results=True).execute(snippet['statement'])
+
     cache = {
       'connection': connection,
       'result': result,
       'meta': [{
-          'name': col[0] if type(col) is dict or type(col) is tuple else col,
+          'name': col[0] if (type(col) is tuple or type(col) is dict) else col.name if hasattr(col, 'name') else col,
           'type': 'STRING_TYPE',
           'comment': ''
         } for col in result.cursor.description]
@@ -320,4 +321,4 @@ class Assist():
       result = connection.execution_options(stream_results=True).execute(statement)
       return result.cursor.description, result.fetchall()
     finally:
-      connection.close()
+      connection.close()

+ 2 - 0
docs/docs-site/content/administrator/configuration/editor/_index.md

@@ -237,6 +237,8 @@ Then give Hue the information about the database source:
 The dialect should be added to the Python system or Hue Python virtual environment:
 
       ./build/env/bin/pip install psycopg2
+      or
+      ./build/env/bin/pip install psycopg2-binary
 
 Then give Hue the information about the database source:
 

+ 1 - 0
tools/kubernetes/helm/hue/templates/hue-postgres.yaml

@@ -6,6 +6,7 @@ spec:
   ports:
   - name: pgql
     port: 5432
+  type: NodePort
   selector:
     app: hue-postgres
 ---