def retrieve_from_fts(cls, search_query, start_index=0, limit=None): ix = open_dir(LOCAL_FTS_INDEX) with ix.searcher() as searcher: parser = QueryParser("content", ix.schema) query = parser.parse(search_query) results_obj = searcher.search(query) results = [dict(uuid=r["id"], tags=r["tags"]) for r in results_obj] return bound_array(results, start_index, limit)
def retrieve_attr_from_db(cls, attr, value, table_name, start_index=0, limit=None): result = cls.run_query( r"select * from {0} where {1}=:{1}".format(table_name, attr, attr), {attr: value}, commit=False ) return bound_array(result, start_index, limit)
def retrieve_multiple_attr_from_db(cls, attrs, values, table_name, relation=OR, start_index=0, limit=None): where_clause = cls.get_where_clause(attrs, values, relation) result = cls.run_query( r"select * from {} where {}".format(table_name, where_clause), dict(zip(attrs, values)), commit=False ) return bound_array(result, start_index, limit)
def retrieve_all_from_table(cls, table_name, start_index=0, limit=None): return bound_array(cls.run_query(r"select * from {}".format(table_name), commit=False), start_index, limit)