7

I'm wanting to deliver some data from the server-side to some client-side Javascript which can use said data to construct a database/table, and then query it using some user-input SQL.

Persistence of data isn't what I'm looking for, so HTML5 stuff like localStorage isn't relevant, I'm only wanting to be able to create something like a mini-database in Javascript to query.

Is there any Javascript libraries that have this capability?

Thanks.

3 Answers 3

2

Take a look at TrimQuery.

Sign up to request clarification or add additional context in comments.

Comments

1

I'd take a look at TaffyDB. It's a database implemented in JavaScript that you can 'query' with objects that resemble where clauses. It's not identical to SQL, but it's close enough that if you're already trusting your users to write queries they should be able to get the hang of it.

Comments

0

You can try Alasql database. It is a JavaScript database with standard 'good old' SQL syntax.

  <script src="alasql.js"></script>  
  <script>
      alasql("CREATE TABLE test (language INT, hello STRING)");
      alasql("INSERT INTO test VALUES (1,'Hello!')");
      alasql("INSERT INTO test VALUES (2,'Aloha!')");
      alasql("INSERT INTO test VALUES (3,'Bonjour!')");
      console.log(alasql("SELECT * FROM test WHERE language > 1"));
  </script>

You can check SQL support with a playground sample in jsFiddle.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.