How to use the alasql.promise 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 / bin / alasql-cli.js View on Github external
if(0===sql.trim().length){
	yargs.showHelp();
	process.exit(1);
}

for(var i=1;i
github agershun / alasql / examples / promise.js View on Github external
// Async select

var db = require('alasql');

db("CREATE TABLE test (language INT, hello STRING)");
db("INSERT INTO test VALUES (1,'Hello!')");
db("INSERT INTO test VALUES (2,'Aloha!')");
db("INSERT INTO test VALUES (3,'Bonjour!')");

db	.promise("SELECT * FROM test WHERE language > 1")
	.then(function(res){
		console.log(res);
	});
github plotly / falcon / backend / persistent / datastores / csv.js View on Github external
function query(queryString, connection) {
    const data = getData(connection);

    // In the query `SELECT * FROM ?`, alaSQL replaces ? with data
    return alasql.promise(queryString, [data]).then(parseSQL);
}
github Olow304 / sqData / src / components / protected / Dashboard.js View on Github external
handelSQLTable = () => {
        const {sqlData} = this.state;
        const {code} = this.state;
        const query = code
    
        const sqlQuery = query
        var name = this.state.nameData;

        name = sqlData;
        const word = `${this.state.nameData}`
        if(sqlQuery.includes(word)){
            const stripped = sqlQuery.replace(/from/g, 'from ?').replace(/'/g, "`");
            alasql.promise(stripped, [name]).then((res) =>{
                var sCols = []
                Object.keys(res[0]).map(columnName => {
                    sCols.push(columnName)
                })
                this.setState({sqlCols: sCols})
    
                var sRows = res.map(Object.values);
                this.setState({sqlRows: sRows})                
                this.setState({
                    finalSQL: res,
                    showCharts: true,
                    tableCharts: [this.state.sqlCols, this.state.sqlRows]
                })
    
                var objectArr = [];
                sRows.map(r => {
github sasha-alias / sqltabs / src / connectors / alasql / Database.js View on Github external
runQuery: function(id, connstr, password, query, callback, err_callback){

        var response = new Response(query)

        try {
            alasql.promise(query)
            .then(function(res){
                response.finish();
                response.processData(res);
                callback(id, [response]);
            })
            .catch(function(err) {
                err_callback(id, err);
            });
        } catch(err) {
            err_callback(id, err);
        }
    },

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

89 / 100
Full package analysis