You can try Alasql. It supports standard SQL language and keeps data in memory or localStorage.
There are sevelar ways, how to use Alasql with localStorage. Below you can see how to create localStorage database with name "Atlas", attach it to Alasql as "MyAtlas", then you can work with tables like any other database. By default, Alasql uses AUTOCOMMIT ON mode, so it saves data to localStorage after each SQL statement.
This is a sample:
alasql( CREATE localStorage DATABASE IF NOT EXISTS Atlas );
alasql( ATTACH localStorage DATABASE Atlas AS MyAtlas );
alasql( CREATE TABLE IF NOT EXISTS MyAtlas.City (city string, population number) );
alasql( SELECT * INTO MyAtlas.City FROM ? ,[[{city: Vienna , population:1731000},
{city: Budapest , population:1728000}]]);
var res = alasql( SELECT * FROM MyAtlas.City );
Play with this sample in jsFiddle. Run this sample two or three times (or reload page), and you will see, how the number of lines will grow in the table.