36 lines
637 B
JavaScript
36 lines
637 B
JavaScript
|
|
|
|
|
|
var HyriseSqlConnector = function(host, port) {
|
|
|
|
this.setConnectionDetails(host, port);
|
|
|
|
}
|
|
|
|
|
|
HyriseSqlConnector.prototype.setConnectionDetails = function(host, port) {
|
|
this._host = host;
|
|
this._port = port;
|
|
return this;
|
|
};
|
|
|
|
HyriseSqlConnector.prototype.executeQuery = function(query, callback, error_callback) {
|
|
var endpoint = 'http://' + this._host + ':' + this._port + '/query';
|
|
var url = encodeURI(endpoint);
|
|
|
|
jQuery.ajax({
|
|
type: "POST",
|
|
url: url,
|
|
dataType: 'json',
|
|
data: {
|
|
performance: true,
|
|
sql: query
|
|
},
|
|
success: function(result) {
|
|
callback(result);
|
|
},
|
|
error: error_callback
|
|
});
|
|
|
|
return this;
|
|
}; |