Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
//
// AlaSQL node.js sample
//
var alasql = require('alasql');
var db = new alasql.Database();
db.exec("CREATE TABLE test (one INT, two INT)");
db.tables.test.data = [ // You can mix SQL and JavaScript
{one:3,two:4},
{one:5,two:6},
];
var res = db.exec("SELECT * FROM test ORDER BY two DESC");
console.log(res);
let columns: string[] = [];
let lines: string[][] = [];
let i = 0;
for ( let row of table.rows ) {
if ( 0 === i ) {
columns = row.cells;
} else {
lines.push( row.cells );
}
++i;
}
*/
// Creating/using the database
// @ts-ignore
let db = new alasql.Database( this._dbName );
let insert: any = null;
let i = 0;
const rowCount = table.rows.length;
let valTypes: ValueType[] = [];
for ( let row of table.rows ) {
if ( 0 === i ) {
alasql( this._sqlHelper.generateUse( this._dbName ) );
if ( rowCount > 1 ) {
valTypes = this._valueTypeDetector.detectAll( table.rows[ 1 ].cells );
const sqlTypes = valTypes.map( v => this._sqlHelper.convertToSQLType( v ) );
const sqlColumns = this._sqlHelper.generateSqlColumns( row.cells, sqlTypes );
};
}
var client = clientFromURL(cluster.cluster.server, x509);
var user = findByName(doc.users, context.context.user);
if (user && user.user.token && user.user.token != 'none') {
client.token = user.user.token;
}
d.resolve(client);
}
});
return d.promise;
};
var mybase = new alasql.Database('mybase');
var create_tables = function(db) {
db.exec('CREATE TABLE pods (uid TEXT, node TEXT, metadata Object, spec Object, status Object)');
db.exec('CREATE TABLE nodes (name TEXT, uid TEXT, metadata Object, spec Object, status Object)');
db.exec('CREATE TABLE services (name TEXT, uid TEXT, metadata Object, spec Object, status Object)');
db.exec('CREATE TABLE containers (image TEXT, uid TEXT, restarts INT)');
};
var process_result = function(res) {
var headers = [];
for (var field in res[0]) {
headers.push(field);
}
var table = [];
for (var i = 0; i < res.length; i++) {
var data = [];