sqlite rewritten
added some tests