superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From johnbod...@apache.org
Subject [incubator-superset] 01/03: [testconn] Explicit closing engine connection (#7570)
Date Fri, 24 May 2019 03:29:06 GMT
This is an automated email from the ASF dual-hosted git repository.

johnbodley pushed a commit to branch release--0.32
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git

commit 0d45abc680f2083225229e8b10d25446c5df6c28
Author: John Bodley <4567245+john-bodley@users.noreply.github.com>
AuthorDate: Wed May 22 09:42:03 2019 -0700

    [testconn] Explicit closing engine connection (#7570)
    
    
    (cherry picked from commit e5739fbbd2eb9150a5ec889cd38f588501945a43)
---
 superset/views/core.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/superset/views/core.py b/superset/views/core.py
index 6d52988..c8c3275 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 # pylint: disable=C,R,W
+from contextlib import closing
 from datetime import datetime, timedelta
 import inspect
 import logging
@@ -36,7 +37,7 @@ from flask_babel import lazy_gettext as _
 import pandas as pd
 import simplejson as json
 import sqlalchemy as sqla
-from sqlalchemy import and_, create_engine, MetaData, or_, update
+from sqlalchemy import and_, create_engine, MetaData, or_, select, update
 from sqlalchemy.engine.url import make_url
 from sqlalchemy.exc import IntegrityError
 from werkzeug.routing import BaseConverter
@@ -1778,8 +1779,9 @@ class Superset(BaseSupersetView):
                 connect_args['configuration'] = configuration
 
             engine = create_engine(uri, **engine_params)
-            engine.connect()
-            return json_success(json.dumps(engine.table_names(), indent=4))
+
+            with closing(engine.connect()) as conn:
+                return json_success(json.dumps(conn.scalar(select([1]))))
         except Exception as e:
             logging.exception(e)
             return json_error_response((


Mime
View raw message