Explorar el Código

[sqlalchemy] Hadle when /autocomplete API used to check if table exists

Romain Rigaux hace 4 años
padre
commit
ceb26e639e
Se han modificado 1 ficheros con 5 adiciones y 1 borrados
  1. 5 1
      desktop/libs/notebook/src/notebook/connectors/sql_alchemy.py

+ 5 - 1
desktop/libs/notebook/src/notebook/connectors/sql_alchemy.py

@@ -598,7 +598,11 @@ class Assist(object):
 
   def get_keys(self, database, table):
     meta = MetaData()
-    metaTable = Table(table, meta, schema=database, autoload=True, autoload_with=self.engine)
+    try:
+      metaTable = Table(table, meta, schema=database, autoload=True, autoload_with=self.engine)
+    except ProgrammingError:
+      LOG.debug("Table %s.%s could not be found and this is probably expected" % (database, table))
+      return {}
 
     return {
       'foreign_keys': [{