Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A simpe SQL parser and pretend DB written in JavaScript

NotificationsYou must be signed in to change notification settings

maciakl/jQuery-SQL-Emulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSQ is a simple SQL parser and pretend-database written in JavaScript with jQuery. It can be used to teach students simple SELECT SQL statements without access to a real database. The database here is basically a JSON object.

Details

Here is the general idea: I want to be able to show how SQL works without the need of setting up a database. JSQ is purely client side app that will run just about anywhere. You set up a mock database as a JSON file (let's call itdb.json) formated like this:

{ "kitchen" : [{"id": 1, "name": "chair"}, {"id": 2, "name": "table"}, {"id": 3, "name": "sink"}, {"id": 4, "name": "stool"}]}

Put it somewhere on your server. Then you can just do:

var sql = 'select id, name from kitchen';var db = 'db.json';JSQ.query(sql, db, function(result){        document.write(result);});

Seeexample.html for a more detailed example of how to use it with a live form.

You can read about implementation details and inspiration for this project inthis old blog post.

Things that work:

  • Simple select statements:select firstname, lastname from students where gpa > 3.0

Things that do not work:

  • Theselect * idiom is not implemented
  • No aggregation functions likesum orcount
  • Noorder by clause
  • No joins of any kind (single table operations only)
  • Some syntax is problematic (eggpa > 2.0 works butgpa>2.0 does not)

Dependencies:

JSQ depends on the following components:

Development time dependencies are:

You can easily install these dependencies usingBower by going to the project directory:

bower install

This will create acomponents folder in that directory with all the dependencies. If you do this, thenexample.html should just work. If you don't want to use Bower then simply download latest jQuery and Dot String plugin and modify the links in the example file.

Running Example

The example file makes a json request so you need a server. If you don't have one, just rungrunt from the project directory. You will need node.js and grunt.js to do this. Added bonus is that grunt will lint the Javascript for you.

About

A simpe SQL parser and pretend DB written in JavaScript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp