Skip to content

Instantly share code, notes, and snippets.

@kiichi
Last active December 14, 2021 02:07
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kiichi/76583589ed2a92775ef0607f89d42157 to your computer and use it in GitHub Desktop.
Save kiichi/76583589ed2a92775ef0607f89d42157 to your computer and use it in GitHub Desktop.
Use alasql in Vue.js
<script>
export default {
mounted(){
this.alasql("CREATE TABLE cities (city string, population number)");
this.alasql("INSERT INTO cities VALUES ('Rome',2863223),('Paris',2249975),('Berlin',3517424),('Madrid',3041579)");
var res = this.alasql("SELECT * FROM cities WHERE population < 3500000 ORDER BY population DESC");
console.log(res);
}
}
</script>
// Other Vue.js imports etc...
import alasqlJs from '../node_modules/alasql/dist/alasql.min.js'
const alasql = {
install (v) {
Vue.prototype.alasql = alasqlJs
}
}
Vue.use(alasql)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment