Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if(0===sql.trim().length){
yargs.showHelp();
process.exit(1);
}
for(var i=1;i
// 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);
});
function query(queryString, connection) {
const data = getData(connection);
// In the query `SELECT * FROM ?`, alaSQL replaces ? with data
return alasql.promise(queryString, [data]).then(parseSQL);
}
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 => {
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);
}
},