WebSQL syntax on IndexedDb
Asked Answered
I

2

5

I have an application that use WebSQL. I want to support IndexedDB too (For Browsers without WebSql support). Is there any libary that use sql-syntax but works with indexedDB / LocalStorage in background?

I don't want to change all my querys and functions.

All libraries i found uses IndexedDb syntax and support WebSql. (Not what I need).

Thanks :)

Ier answered 13/2, 2014 at 14:12 Comment(1)
Take a look at jsstore.net. It provides sql like syntax.Clasping
G
2

You can use my library, ydn-db, for very simple sql query, which works with any web database.

For near full support for SQL, check out commercial SequelSphere js library http://www.sequelsphere.com/docs/latest/doc/Supported%20SQL.html. Unfortunately query execution is in-memory currently. Pricing is outrageously greedy.

Glut answered 16/2, 2014 at 1:37 Comment(0)
S
8

You can try Alasql JavaScript SQL database library. It supports all important SQL statements and can work with IndexedDB with SQL syntax as well.

Here is an example:

<script src='alasql.min.js'></script>
<script>
    var cityData = [{city:"Redmond", population:57530},
        {city:"Atlanta",population:447841},
        {city:"San Francisco", population:837442}];

    // Create IndexdDB database and fill it with data from array
    alasql('CREATE INDEXEDDB DATABASE IF NOT EXISTS geo;\
        ATTACH INDEXEDDB DATABASE geo; \
        USE geo; \
        DROP TABLE IF EXISTS cities; \
        CREATE TABLE cities; \
        SELECT * INTO cities FROM ?', [cityData], function(){

        // Select data from IndexedDB
        alasql('SELECT COLUMN * FROM cities WHERE population > 100000 ORDER BY city DESC',
           [],function(res){
                document.write('Big cities: ', res.join(','));
        });
    });
</script>

You can play with this example in jsFiddle

Snitch answered 14/12, 2014 at 7:54 Comment(0)
G
2

You can use my library, ydn-db, for very simple sql query, which works with any web database.

For near full support for SQL, check out commercial SequelSphere js library http://www.sequelsphere.com/docs/latest/doc/Supported%20SQL.html. Unfortunately query execution is in-memory currently. Pricing is outrageously greedy.

Glut answered 16/2, 2014 at 1:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.