How to use the alasql.Database function in alasql

To help you get started, we’ve selected a few alasql examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github agershun / alasql / examples / nodesample.js View on Github external
//
// 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);
github thiagodp / concordialang / modules / db / InMemoryTableCreator.ts View on Github external
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 );
github brendandburns / ksql / ksql.js View on Github external
};
      }

      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 = [];

alasql

Use SQL to select and filter javascript data - including relational joins and search in nested objects (JSON). Export to and import from Excel and CSV

MIT
Latest version published 2 months ago

Package Health Score

87 / 100
Full package analysis