Browse Source

HUE-9270 [sqlalchemy] Rename CONNECTION_CACHE to CONNECTIONS

Romain 5 years ago
parent
commit
92857c1f75
1 changed files with 10 additions and 6 deletions
  1. 10 6
      desktop/libs/notebook/src/notebook/connectors/sql_alchemy.py

+ 10 - 6
desktop/libs/notebook/src/notebook/connectors/sql_alchemy.py

@@ -77,7 +77,7 @@ else:
 
 
 
 
 ENGINES = {}
 ENGINES = {}
-CONNECTION_CACHE = {}
+CONNECTIONS = {}
 
 
 LOG = logging.getLogger(__name__)
 LOG = logging.getLogger(__name__)
 
 
@@ -194,7 +194,7 @@ class SqlAlchemyApi(Api):
         for col in result.cursor.description
         for col in result.cursor.description
       ] if result.cursor else []
       ] if result.cursor else []
     }
     }
-    CONNECTION_CACHE[guid] = cache
+    CONNECTIONS[guid] = cache
 
 
     return {
     return {
       'sync': False,
       'sync': False,
@@ -212,7 +212,7 @@ class SqlAlchemyApi(Api):
   @query_error_handler
   @query_error_handler
   def check_status(self, notebook, snippet):
   def check_status(self, notebook, snippet):
     guid = snippet['result']['handle']['guid']
     guid = snippet['result']['handle']['guid']
-    connection = CONNECTION_CACHE.get(guid)
+    connection = CONNECTIONS.get(guid)
 
 
     response = {'status': 'canceled'}
     response = {'status': 'canceled'}
 
 
@@ -229,7 +229,7 @@ class SqlAlchemyApi(Api):
   @query_error_handler
   @query_error_handler
   def fetch_result(self, notebook, snippet, rows, start_over):
   def fetch_result(self, notebook, snippet, rows, start_over):
     guid = snippet['result']['handle']['guid']
     guid = snippet['result']['handle']['guid']
-    handle = CONNECTION_CACHE.get(guid)
+    handle = CONNECTIONS.get(guid)
 
 
     if handle:
     if handle:
       data = handle['result'].fetchmany(rows)
       data = handle['result'].fetchmany(rows)
@@ -283,15 +283,19 @@ class SqlAlchemyApi(Api):
 
 
     try:
     try:
       guid = snippet['result']['handle']['guid']
       guid = snippet['result']['handle']['guid']
-      connection = CONNECTION_CACHE.get(guid)
+      connection = CONNECTIONS.get(guid)
       if connection:
       if connection:
         connection['connection'].close()
         connection['connection'].close()
-        del CONNECTION_CACHE[guid]
+        del CONNECTIONS[guid]
       result['status'] = 0
       result['status'] = 0
     finally:
     finally:
       return result
       return result
 
 
 
 
+  def close_session(self, session):
+    pass
+
+
   @query_error_handler
   @query_error_handler
   def autocomplete(self, snippet, database=None, table=None, column=None, nested=None):
   def autocomplete(self, snippet, database=None, table=None, column=None, nested=None):
     engine = self._get_engine()
     engine = self._get_engine()