Include connection parameters in call to Test Connection for a new database (#326)

This commit is contained in:
Denis Zgonjanin 2016-04-11 18:39:50 -04:00 committed by Maxime Beauchemin
parent 9ac979a336
commit 6d0b5767b3
3 changed files with 7 additions and 5 deletions

View File

@ -111,7 +111,7 @@ export PATH="$HOME/.node/bin:$PATH"
#### npm packages #### npm packages
To install third party libraries defined in `package.json`, run the To install third party libraries defined in `package.json`, run the
following within this directory which will install them in a following within the `caravel/assets/` directory which will install them in a
new `node_modules/` folder within `assets/`. new `node_modules/` folder within `assets/`.
``` ```

View File

@ -7,8 +7,9 @@
$.ajax({ $.ajax({
method: "POST", method: "POST",
url: url, url: url,
data: { uri: $("#sqlalchemy_uri").val() }, data: JSON.stringify({ uri: $("#sqlalchemy_uri").val(), extras: JSON.parse($("#extra").val()) }),
dataType: 'json' dataType: 'json',
contentType: "application/json; charset=utf-8"
}).done(function(data) { }).done(function(data) {
alert("Seems OK!"); alert("Seems OK!");
if ($('#tables').length == 0) if ($('#tables').length == 0)

View File

@ -629,8 +629,9 @@ class Caravel(BaseView):
def testconn(self): def testconn(self):
"""Tests a sqla connection""" """Tests a sqla connection"""
try: try:
uri = request.form.get('uri') uri = request.json.get('uri')
engine = create_engine(uri) connect_args = request.json.get('extras', {}).get('engine_params', {}).get('connect_args')
engine = create_engine(uri, connect_args=connect_args)
engine.connect() engine.connect()
return json.dumps(engine.table_names(), indent=4) return json.dumps(engine.table_names(), indent=4)
except Exception: except Exception: