开发者

Javascript SQL database

开发者 https://www.devze.com 2023-01-13 05:31 出处:网络
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.

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 stu开发者_开发百科ff 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.


Take a look at TrimQuery.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消