Commit b860dc59 authored by Romain Casati's avatar Romain Casati
Browse files

Simple SQL kernel.

parent 4a440a79
......@@ -3,7 +3,7 @@ var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var sourcemaps = require('gulp-sourcemaps');
const kernels = ['python', 'javascript'];
const kernels = ['python', 'javascript', 'sql'];
function gulp_task_kernel(kernel_name) {
return gulp.task(kernel_name, function() {
......
(function (root, factory) {
// requirejs?
if (typeof define === 'function') {
define(['./basthon_base'], factory);
// TypeScript?
} else if (typeof exports === 'object') {
module.exports = factory();
// default goes to global namespace
} else {
root.Basthon = factory(BasthonBase);
}
}(this, function (BasthonBase) {
'use strict';
class Basthon extends BasthonBase {
constructor() {
super();
this.execution_count = 0;
};
version () { return "0.0.0" };
language () { return "SQL"; };
async launch () {
await this.loadScript("https://cdnjs.cloudflare.com/ajax/libs/sql.js/1.5.0/sql-wasm.min.js");
const SQL = await window.initSqlJs({
locateFile: file => `https://sql.js.org/dist/${file}`
});
this.db = new SQL.Database();
await this.pageLoad();
};
async evalAsync (code, outCallback, errCallback, data=null) {
// force interactivity in all modes
data.interactive = true;
let result = this.db.exec(code);
// return result
if( typeof result !== 'undefined' )
result = {'text/plain': JSON.stringify(result),
'text/html': result};
return [result, ++this.execution_count];
};
ps1 () { return "sql> "; };
ps2 () { return "...> "; };
restart () { };
more (source) { return false; };
complete (code) { return []; };
}
return new Basthon();
}));
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment