瀏覽代碼

[rdbms] Fall back to database from conn_params on failure to fetch from Postgres information_schema

As reported in: https://groups.google.com/a/cloudera.org/forum/#\!topic/hue-user/-vGaidc6biQ
Jenny Kim 10 年之前
父節點
當前提交
f1d916edbd
共有 1 個文件被更改,包括 8 次插入4 次删除
  1. 8 4
      desktop/libs/librdbms/src/librdbms/server/postgresql_lib.py

+ 8 - 4
desktop/libs/librdbms/src/librdbms/server/postgresql_lib.py

@@ -83,10 +83,14 @@ class PostgreSQLClient(BaseRDMSClient):
 
   def get_databases(self):
     # List all the schemas in the database
-    cursor = self.connection.cursor()
-    cursor.execute('SELECT schema_name FROM information_schema.schemata')
-    self.connection.commit()
-    return [row[0] for row in cursor.fetchall()]
+    try:
+      cursor = self.connection.cursor()
+      cursor.execute('SELECT schema_name FROM information_schema.schemata')
+      self.connection.commit()
+      return [row[0] for row in cursor.fetchall()]
+    except Exception:
+      LOG.exception('Failed to select schema_name from information_schema')
+      return [self._conn_params['database']]
 
 
   def get_tables(self, database, table_names=[]):